the following is the code that I am using to insert data. It is picked up from the samples which Google provided.
// Get the spreadsheet feed
SpreadsheetFeed feed = client
.getFeed(
new URL(
"https://spreadsheets.google.com/feeds/spreadsheets/private/full"),
SpreadsheetFeed.class);
// Get the worksheet
WorksheetEntry worksheet = feed.getEntries().get(0).getWorksheets()
.get(0);
URL listFeed = worksheet.getListFeedUrl();
ListEntry newEntry = new ListEntry();
String nameValuePairs = "a=b,c=d";
for (String nameValuePair : nameValuePairs.split(",")) {
// Then, split by the equal sign.
String[] parts = nameValuePair.split("=", 2);
String tag = parts[0]; // such as "name"
String value = parts[1]; // such as "Fred"
newEntry.getCustomElements().setValueLocal(tag, value);
}
client.insert(listFeed, newEntry);
What I am trying to do there is to get a worksheet and insert a row of data into it. No matter how much I try, I am not able to make it work. I get the following error whenever I run it on client.insert()
com.google.gdata.util.InvalidEntryException: Bad Request
We're sorry, a server error occurred. Please wait a bit and try reloading your spreadsheet.
I figured out that you need to have at least one row in the spreadsheet which behaves as header and reference for the tag values you are sending while inserting the listentry. I was missing this.
Thank you.