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 に答える