我正在尝试重命名一个集合,但是我收到错误但是
com.google.gdata.util.InvalidEntryException:无效的请求URI
,这是我的代码
DocsService client = new DocsService(“test testApp v1”);
URL feedUrl = new URL("https://docs.google.com/feeds/default/private/full/folder%3A"+IDFOLDER);
DocumentListEntry newEntry = new FolderEntry();
newEntry.setId(IDFOLDER);
newEntry.setTitle(new PlainTextConstruct(newName));
client.insert(feedUrl, newEntry);
这是做错的方法还是我错了?
答案 0 :(得分:3)
重命名集合(或文档条目)类似于从API检索条目,更改标题并向文档条目的编辑URL发送更新(PUT)请求。 您可以使用此代码段在Java中完成此任务:
static DocumentListEntry renameDocument(DocsService client, String resourceUrl,
String newTitle) throws MalformedURLException, IOException,
ServiceException {
DocumentListEntry entry = client.getEntry(
new URL(resourceUrl), DocumentListEntry.class);
entry.setTitle(new PlainTextConstruct(newTitle));
DocumentListEntry updatedEntry = client.update(
new URL(entry.getEditLink().getHref()), entry);
// Check that updatedEntry has the new title.
return updatedEntry;
}