Can anyone share a code snippet to Update Google Documents
- by Sana
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.