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;
}
精彩评论