Question

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.

Was it helpful?

Solution

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!

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top