How to change picture in google app contacts api?

1 view
Skip to first unread message

user1686253 via StackOverflow

unread,
Dec 5, 2012, 2:13:24 AM12/5/12
to google-appengin...@googlegroups.com

I want to change the picture in contacts api but i got some exception please check my code

String filepath="C:\\Users\\bhanuprasad\\Documents\\Downloads\\549002_459129587462191_1689883124_n.jpg";
    File file = new File(filepath);

    byte[] photoData = new byte[(int) file.length()];
String url="https://www.google.com/m8/feeds/profiles/domain/"+ sDomain + "/full/pcvita1111qaeteam10?xoauth_requestor_id=apps...@soharcoas.com" ;
    ContactEntry profile = contactService.getEntry(
            new URL(url),ContactEntry.class);
 GDataRequest request = contactService.createRequest(GDataRequest.RequestType.UPDATE,
          photoUrl, new ContentType("image/jpeg"));

      request.setEtag(photoLink.getEtag());
    OutputStream requestStream = request.getRequestStream();
      requestStream.write(photoData);
     request.execute();

when i call request.execute(); i got following exception

com.google.gdata.util.InvalidEntryException: Bad Request Invalid image file

at com.google.gdata.client.http.HttpGDataRequest.handleErrorResponse(HttpGDataRequest.java:594)
at com.google.gdata.client.http.GoogleGDataRequest.handleErrorResponse(GoogleGDataRequest.java:563)
at com.google.gdata.client.http.HttpGDataRequest.checkResponse(HttpGDataRequest.java:552)
at com.google.gdata.client.http.HttpGDataRequest.execute(HttpGDataRequest.java:530)
at com.google.gdata.client.http.GoogleGDataRequest.execute(GoogleGDataRequest.java:535)

please help me....



Please DO NOT REPLY directly to this email but go to StackOverflow:
http://stackoverflow.com/questions/13718051/how-to-change-picture-in-google-app-contacts-api
Reply all
Reply to author
Forward
0 new messages