2

我正在尝试重命名一个集合,但我收到错误但是

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);

这是这样做的方法还是我做错了什么?

4

1 回答 1

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;
}
于 2012-04-10T19:03:10.033 回答