4 messages in com.googlegroups.google-base-data-apiRe: Java Client Insert Example Broken
FromSent OnAttachments
afisk10 Sep 2006 08:48 
Vishal21 Sep 2006 08:53 
Adam Fisk21 Sep 2006 19:51 
Vishal21 Sep 2006 22:46 
Subject:Re: Java Client Insert Example Broken
From:Adam Fisk (adam@gmail.com)
Date:09/21/2006 07:51:37 PM
List:com.googlegroups.google-base-data-api

I ended up just coding my own using HttpClient and JDOM. Was actually a breeze, but I've used both tools a lot.

On 9/21/06, Vishal <sing@gmail.com> wrote:

Same problem with me.. Any luck with a solution

Thanks Vishal

afisk wrote:

The example insert code is broken, returning "com.google.gdata.util.InvalidEntryException: Bad Request" every time. This is with copying the code exactly. My key and user name password are working fine in othere tests, but as soon as I swap in the example code from the site, it just doesn't work.

Here's my code if you'd like to reproduce. Again, the relevant parts are just copied straight from the example to get things running:

public class GBase {

public static void main(String[] args) { final GBase base = new GBase(); base.start(); }

private void start() { final GoogleBaseService service = new GoogleBaseService("Google.-CustomerTool-1.0", "ABQIAFXhHIE--key-key-key--r0fOwQZgTbA"); try { service.setUserCredentials("myusername", "mypassword"); final FeedURLFactory urlFactory = FeedURLFactory.getDefault(); final URL url = urlFactory.getItemsFeedURL();

GoogleBaseEntry entry = new GoogleBaseEntry();

entry.setTitle(TextConstruct.create(TextConstruct.Type.TEXT, "My House", null));

entry.setContent(TextConstruct.create(TextConstruct.Type.TEXT, "The best house of the area.", null)); entry.getGoogleBaseAttributes().setItemType("test"); entry.getGoogleBaseAttributes().addTextAttribute("my attribute", "hello");

entry.getGoogleBaseAttributes().addFloatAttribute("bathrooms", 2f); entry.getGoogleBaseAttributes().addFloatAttribute("rooms", 6.5f);

entry.getGoogleBaseAttributes().addFloatAttribute("bedrooms", 2f);

entry.getGoogleBaseAttributes().addLocationAttribute("location", "1900 Snow Cone Avenue, North Pole"); service.insert(url, entry); } catch (AuthenticationException e) { // TODO Auto-generated catch block e.printStackTrace(); } catch (IOException e) { // TODO Auto-generated catch block e.printStackTrace(); } catch (ServiceException e) { // TODO Auto-generated catch block e.printStackTrace(); } } }