Can anyone share a code snippet to Update Google Documents
Posted
by
Sana
on Stack Overflow
See other posts from Stack Overflow
or by Sana
Published on 2011-03-13T08:05:02Z
Indexed on
2011/03/13
8:10 UTC
Read the original article
Hit count: 274
Hi,
I am relentlessly trying to update an existing google doc with the Google Protocol Data API, but the contents do not get updated, even though the PUT runs perfectly fine with a return response code of 200.
Here is the code that I am using
try {
HttpRequest requestPost = transport.buildPutRequest();
requestPost.url = DocsUrl.forUploadingFile(editLink);
((GoogleHeaders) requestPost.headers).setSlugFromFileName("books1.xml");
InputStreamContent content = new InputStreamContent();
File file = new File("//sdcard/books.xml");
content.setFileInput(file);
content.type = "text/plain";
content.length = file.length();
System.out.println("Length of the file = "+content.length);
requestPost.content = content;
HttpResponse responseUpload = requestPost.execute();
System.out.println("Uploading code = "+responseUpload.statusCode);
}
catch (FileNotFoundException e) {
e.printStackTrace();
}
catch (ClientProtocolException e) {
System.out.println("Client Protocol Exception");
}
catch (IOException e) {
handleException(e);
}
where editLink is the editLink edit-media
link returned from google doc feeds.
© Stack Overflow or respective owner