【问题标题】:Rename a folder / Collection with Google Documents List Data API v3.0使用 Google Documents List Data API v3.0 重命名文件夹/集合
【发布时间】:2011-08-10 17:49:32
【问题描述】:

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

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

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

【问题讨论】:

  • 请停止使用 google-app-engine 标记这些问题。

标签: google-api google-docs-api google-data-api google-data


【解决方案1】:

重命名集合(或文档条目)类似于从 API 检索条目、更改标题并向文档条目的编辑 URL 发送更新 (PUT) 请求。 您可以使用此代码 sn-p 在 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;
}

【讨论】:

  • 我实际上把简约的 XML: w3.org/2005/Atom"> %s 这似乎成功地重命名了文件/文件夹。
猜你喜欢
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 2011-09-06
  • 1970-01-01
  • 2011-08-08
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
相关资源
最近更新 更多