1

I am trying to learn how to use the Google Spreadsheets API through the Developer's Guide: Java. My application can authenticate to the spreadsheets service,retrieve a worksheet-based feed and create a table. The next step would be to create a table record what I am trying to do. My problem is when I run the application I obtain this error :

Service failure
com.google.gdata.util.InvalidEntryException: Bad Request
[Line 1, Column 429, element entry] Required extension element  http://schemas.google.com/spreadsheets/2006:header not found.

This is the code part for the creation of the table :

//Creating a table record
String nameValuePairs = "Column A=Rosa";
RecordEntry entryToChange = new RecordEntry();
// Split first by the commas between the different fields.
for (String nameValuePair : nameValuePairs.split(",")) {
    // Then split by the equal sign.
    String[] parts = nameValuePair.split("=", 2);
    String name = parts[0]; // such as "name"
    String value = parts[1]; // such as "Fred"

    entryToChange.addField(new Field(null, name, value));         
}
try {
    myService.insert(tableFeedUrl, entryToChange);
} catch (IOException e) {
    System.err.println("I/0 problem");
    e.printStackTrace();
} catch (ServiceException e) {
    System.err.println("Service failure");
    e.printStackTrace();
}

tableFeedUrl :

tableFeedUrl = factory.getTableFeedUrl(entry.getKey());

entry :

entry = spreadsheets.get(0);

Apparently the problem come from :

myService.insert(tableFeedUrl, entryToChange);

but I am not sure and I don't understand why...

Thank you for your help.

2

1 Answer 1

2

I have found the solution. I answer my own question for those who will have the same problem.

I use :

myService.insert(tableFeedUrl, entryToChange);

"tableFeedUrl" corresponds to :

http://spreadsheets.google.com/feeds/<key>/tables/

this's not the right link to access to the table (the doc).

But in the Java developers guide it's notice we have to use :

myService.insert(recordFeedUrl, entryToChange);

"recordFeedUrl" results from :

URL recordFeedUrl = tableEntry.getRecordFeedUrl();

But the method : getRecordFeedUrl() doesn't exist... (the doc)

The solution is to create manually the URL :

recordFeedUrl = new URL(table.getId().toString().replace("tables", "records"));

So the URL corresponds to the table :

https://spreadsheets.google.com/feeds/<key>/records/60

"60" corresponds to the table number.

I hope it will help!

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.