Thanks Eric!! Worked perfectly. You're amazing as always.
In case someone needs the rename doc/spreadsheet code - here it is:
//create a service obj first.
//See DocumentListDemo.java for reference
public void renameSpreadsheet(String initName, String finalName)
throws IOException, ServiceException {
PlainTextConstruct ptc = new PlainTextConstruct();
ptc.setText(finalName);
DocumentListFeed feed =
service.getFeed(new URL(documentListFeedUrl.toString()
+ SPREADSHEET_CATEGORY), DocumentListFeed.class);
for (DocumentListEntry entry : feed.getEntries()) {
if(entry.getTitle().getPlainText().equals(initName)){
entry.setTitle(ptc);
service.update(
new URL(entry.getEditLink().getHref()), entry);
}
}
}
On Mar 3, 7:59 pm, "Eric (Google)" <[email protected]> wrote:
> Hi AN,
>
> This is an update to an existing document (a PUT), so you
> should use:
>
> URL editUrl = new URL(entry.getEditLink().getHref());
> service.update(editUrl, entry);
>
> Eric
>
> On Mar 2, 10:45 pm, AN <[email protected]> wrote:
>
> > Is it possible to rename an existing spreadsheet using the Java API?
>
> > 1. If so - how? I tried the following but it gave an error. Any
> > assistance appreciated!
>
> > ---------------code-------------
> > //I retrieve the spreadsheet entries, iterate to the entry to be
> > renamed and rename it
> > entry.setTitle(ptc);//ptc has the new spreadsheet name
>
> > //Save the entry. The url is the url to retrieve the list of
> > spreadsheets above
> > service.insert(url, entry); //code fails here
>
> > -------------error---------------
>
> > com.google.gdata.util.InvalidEntryException: Bad Request
> > Invalid request URI
> > ----------------------------
>
> > The protocol document says it's possible as follows
>
> > -------------XML POST request for rename---------------
>
> > PUT /feeds/documents/private/full/spreadsheet%3Aspreadsheet_id
> > Host: docs.google.com <http://docs.google.com>
> > Authorization: <your authorization header here>
> > Content-Length: 292
> > Content-Type: application/atom+xml
>
> > <?xml version='1.0' encoding='UTF-8'?>
> > <atom:entry xmlns:atom="http://www.w3.org/2005/Atom"
> > gd:etag="BxAaTxRZAyp7ImBq">
> > <atom:category scheme="http://schemas.google.com/g/2005#kind"
> > term="http://schemas.google.com/docs/2007#spreadsheet" />
> > <atom:title>example spreadsheet</atom:title>
> > </atom:entry>
>
> >http://code.google.com/apis/documents/docs/2.0/developers_guide_proto...
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups
"Google Docs Data APIs" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to
[email protected]
For more options, visit this group at
http://groups.google.com/group/Google-Docs-Data-APIs?hl=en
-~----------~----~----~----~------~----~------~--~---