开发者

Rename a folder / Collection with Google Documents List Data API v3.0

开发者 https://www.devze.com 2023-03-27 08:25 出处:网络
I am trying to rename a collection, but I get the error But com.google.gdata.util.InvalidEntryException: Invalid request URI

I am trying to rename a collection, but I get the error But

com.google.gdata.util.InvalidEntryException: Invalid request URI

, this is the code that I have

DocsService client = new DocsService("test testApp v1");

     URL feedUr开发者_运维百科l = 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);

This is the way to do that or what i have wrong ?


Renaming a collection (or a document entry) is similar to retrieving the entry from the API, changing the title and sending an update (PUT) request to the document entry's edit URL. You can use this code snippet to accomplish that in 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;
}
0

精彩评论

暂无评论...
验证码 换一张
取 消