+ Start a Discussion

Facing Problem in Invoking Google Contact Service


I am trying to invoke Google-Contacts.

Implemented it in two manners:

1. Made used of Contact Service, Google Service and Google Data classes, as given in the salesforce framework.


Invoked method : public static final string defaultFeed = 'http://www.google.com/m8/feeds/contacts/default/full'; static final string sessionAuthToken = 'CJ3pqczuBBCk0tSrBQ'; public static testMethod void getOneContact() { ContactService service = new ContactService(); service.setAuthSubToken(sessionAuthToken); // to get a single contact you must have stored the self // link for that contact GoogleData oneCon = service.getFeed( ContactService.defaultFeed); oneCon.dump(); }



But got this errior:As far as I could make out , we are getting null pointer exception may be becausse response is null , and later xmldom object is created , passing this response as parameter. So then I read with my login account details:  GoogleData oneCon = service.getFeed( myGmailId);  service.setAuthSubToken(myGmailPasswd); 

but still I got the same error.


  {faultcode:'soapenv:Client', faultstring:'System.NullPointerException: Attempt to de-refference a Null Object


Class.GoogleService:line 141, column 58

Class.GoogleData:line 471, column15

Class.ContactService.getFeed : line5 , column 49

Class.ContactService.getContact : line 133, column23',}



Http http = new Http(); HttpResponse response = null; HttpResponse response2=null; req.setEndpoint('https://www.google.com/accounts/Login'); req.setMethod('GET') ; req.setHeader('Authorization','Email=GmailMailId&Passwd=myGmailpasswd); HttpResponse res=http.send(req); resBody=res.getBody(); status=res.getStatus(); headerKey=res.getHeaderKeys(); code=res.getStatusCode(); responseG=res.toString();



It succedd for Login authentication, but then how to access the contact :what does this 'Authorization' denotes.  Can u plz help me into this.. regards Diti