我正在尝试通过开发人员指南:Java 学习如何使用 Google 电子表格 API。我的应用程序可以对电子表格服务进行身份验证,检索基于工作表的提要并创建表格。下一步将是创建一个表记录我正在尝试做的事情。我的问题是当我运行应用程序时出现此错误:
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.
这是创建表的代码部分:
//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();
}
表FeedUrl:
tableFeedUrl = factory.getTableFeedUrl(entry.getKey());
入口 :
entry = spreadsheets.get(0);
显然问题来自:
myService.insert(tableFeedUrl, entryToChange);
但我不确定,我不明白为什么......
谢谢您的帮助。