Hello,
I think what is happening is that when you are calling:
searchContact.delete()
The xoauth_requestor_id query parameter is not part of the URL which makes
the request fail.
Can you try doing this instead:
myService.delete(new URL(searchContact.getEditLink().getHref() +
"?xoauth_requestor_id=<EMAIL>"));
Best,
Alain
On Thu, Dec 15, 2011 at 1:28 AM, Nirzari Bhatt
<[email protected]>wrote:
> Hi Alain,
>
> Thanks for your feedback.
>
> But using Https is also not working for me.
>
> Apart from that I tried creating and deleting private contacts.
>
> using feed url :
> https://www.google.com/m8/feeds/contacts/domainuserEmail/full/
>
> Add and update contacts is working fine for me but while deleting
> contacts I am getting the same exception i.e.
>
> java.lang.NullPointerException: No authentication header information
> at
>
> com.google.gdata.util.AuthenticationException.initFromAuthHeader(AuthenticationException.java:
> 96)
> at
>
> com.google.gdata.util.AuthenticationException.<init>(AuthenticationException.java:
> 67)
> at
>
> com.google.gdata.client.http.HttpGDataRequest.handleErrorResponse(HttpGDataRequest.java:
> 564)
> at
>
> com.google.gdata.client.http.GoogleGDataRequest.handleErrorResponse(GoogleGDataRequest.java:
> 543)
> at
>
> com.google.gdata.client.http.HttpGDataRequest.checkResponse(HttpGDataRequest.java:
> 536)
> at
>
> com.google.gdata.client.http.HttpGDataRequest.execute(HttpGDataRequest.java:
> 515)
> at
>
> com.google.gdata.client.http.GoogleGDataRequest.execute(GoogleGDataRequest.java:
> 515)
> at com.google.gdata.client.Service.delete(Service.java:1560)
> at com.google.gdata.client.GoogleService.delete(GoogleService.java:
> 691)
> at com.google.gdata.data.BaseEntry.delete(BaseEntry.java:647)
> at
>
> com.visy.connector.taskqueue.DeleteContactTaskServlet.doGet(DeleteContactTaskServlet.java:
> 76)
> at
>
> com.visy.connector.taskqueue.DeleteContactTaskServlet.doPost(DeleteContactTaskServlet.java:
> 97)
> at javax.servlet.http.HttpServlet.service(HttpServlet.java:637)
> at javax.servlet.http.HttpServlet.service(HttpServlet.java:717)
> at
> org.mortbay.jetty.servlet.ServletHolder.handle(ServletHolder.java:
> 511)
> at org.mortbay.jetty.servlet.ServletHandler
> $CachedChain.doFilter(ServletHandler.java:1166)
> at
>
> com.google.appengine.tools.development.HeaderVerificationFilter.doFilter(HeaderVerificationFilter.java:
> 35)
> at org.mortbay.jetty.servlet.ServletHandler
> $CachedChain.doFilter(ServletHandler.java:1157)
> at
>
> com.google.appengine.api.blobstore.dev.ServeBlobFilter.doFilter(ServeBlobFilter.java:
> 58)
> at org.mortbay.jetty.servlet.ServletHandler
> $CachedChain.doFilter(ServletHandler.java:1157)
> at
>
> com.google.apphosting.utils.servlet.TransactionCleanupFilter.doFilter(TransactionCleanupFilter.java:
> 43)
> at org.mortbay.jetty.servlet.ServletHandler
> $CachedChain.doFilter(ServletHandler.java:1157)
> at
>
> com.google.appengine.tools.development.StaticFileFilter.doFilter(StaticFileFilter.java:
> 122)
> at org.mortbay.jetty.servlet.ServletHandler
> $CachedChain.doFilter(ServletHandler.java:1157)
> at
>
> com.google.appengine.tools.development.BackendServersFilter.doFilter(BackendServersFilter.java:
> 97)
> at org.mortbay.jetty.servlet.ServletHandler
> $CachedChain.doFilter(ServletHandler.java:1157)
> at
> org.mortbay.jetty.servlet.ServletHandler.handle(ServletHandler.java:
> 388)
> at
> org.mortbay.jetty.security.SecurityHandler.handle(SecurityHandler.java:
> 216)
> at
> org.mortbay.jetty.servlet.SessionHandler.handle(SessionHandler.java:
> 182)
> at
> org.mortbay.jetty.handler.ContextHandler.handle(ContextHandler.java:
> 765)
> at org.mortbay.jetty.webapp.WebAppContext.handle(WebAppContext.java:
> 418)
> at
>
> com.google.apphosting.utils.jetty.DevAppEngineWebAppContext.handle(DevAppEngineWebAppContext.java:
> 70)
> at
> org.mortbay.jetty.handler.HandlerWrapper.handle(HandlerWrapper.java:
> 152)
> at com.google.appengine.tools.development.JettyContainerService
> $ApiProxyHandler.handle(JettyContainerService.java:351)
> at
> org.mortbay.jetty.handler.HandlerWrapper.handle(HandlerWrapper.java:
> 152)
> at org.mortbay.jetty.Server.handle(Server.java:326)
> at
> org.mortbay.jetty.HttpConnection.handleRequest(HttpConnection.java:
> 542)
> at org.mortbay.jetty.HttpConnection
> $RequestHandler.content(HttpConnection.java:938)
> at org.mortbay.jetty.HttpParser.parseNext(HttpParser.java:755)
> at org.mortbay.jetty.HttpParser.parseAvailable(HttpParser.java:218)
> at org.mortbay.jetty.HttpConnection.handle(HttpConnection.java:404)
> at
> org.mortbay.io.nio.SelectChannelEndPoint.run(SelectChannelEndPoint.java:
> 409)
> at org.mortbay.thread.QueuedThreadPool
> $PoolThread.run(QueuedThreadPool.java:582)
>
> Here also I am using two legged authentication.
>
> Below is the code I am using for delete contact
> String urlStr = https://www.google.com/m8/feeds/contacts/ + userEmail
> + "/full/" + "?xoauth_requestor_id=" + userEmail;
> URL feedUrl = new URL(urlStr);
>
> ContactFeed resultFeed = myService.getFeed(feedUrl,
> ContactFeed.class);
> for (int i = 0; i < resultFeed.getEntries().size(); i++) {
> searchContact = resultFeed.getEntries().get(i);
> // Check if the extended property with CRMContactId is there
> for
> // the contact or no
> List<ExtendedProperty> extendedProps =
> searchContact.getExtendedProperties();
> if (extendedProps != null && !extendedProps.isEmpty()) {
> for (ExtendedProperty extendedProperty : extendedProps) {
> if
> (extendedPropName.equals(extendedProperty.getName())
> &&
> crmContactId.equals(extendedProperty.getValue())) {
> isCRMContact = true;
> break;
> }
> }
> if (isCRMContact) {
> break;
> }
> }
> if (searchContact != null){
> searchContact.delete();
> }
>
> Please help me out to figure out what is wrong with the code here.
>
> Regards,
> Nirzari
>
> On Dec 7, 10:16 pm, Alain Vongsouvanh <[email protected]> wrote:
> > Hello,...
> >
> > read more »
> >
> > Please use HTTPS instead of HTTP! Also, what error are you getting?
> >
> > Best,
> > Alain
> >
> > On Tue, Dec 6, 2011 at 3:07 AM, Nirzari Bhatt
> > <[email protected]>wrote:
> >
> >
> >
> > > Hi,
> >
> > > I am also not able to achieve update functionality for domain shared
> > > contacts. There is some problem with the way I am fetching contact
> > > from datastore. Following is the code I am using for fetching
> > > contacts-
> >
> > > ContactsService myService =
> > > ConnectorUtil.getInstance().getOAuthContactService("getContact");
> > > try {
> > > String urlStr = FEED_URL + "/" + contactId +
> > > "?xoauth_requestor_id="
> > > + domainAdminEmail;
> > > LOGGER.log(Level.INFO, "getContactFromGoogle : URL :: " +
> urlStr);
> > > contact = myService.getEntry(new URL(urlStr),
> ContactEntry.class,
> > > contactId);
> > > if (contact != null) {
> > > LOGGER.log(Level.INFO, "INTO
> > > getContactFromGoogle :: Retrieved the contact from Google");
> > > }
> > > } catch (Exception e) {
> > > LOGGER.log(Level.SEVERE, e.getMessage());
> > > }
> >
> > > P.S.
> > > FEED_URL =http://www.google.com/m8/feeds/contacts/domain/full;
> >
> > > It is giving some problem with contactEntry it is returning. Please
> > > help me to figure out what is wrong with it.
> >
> > > Thanks,
> > > Nirzari
> >
> > > On Dec 2, 5:36 pm, Nirzari Bhatt <[email protected]> wrote:
> > > > Hi,
> >
> > > > Thanks for the inputs.But I am already using admin's credentials in
> > > > the url of domain's shared contacts.
> >
> > > > I have also mentioned consumer key and secret in 2 legged OAuth.
> >
> > > > I am still getting the same error.Please help me with this.
> >
> > > > Thanks,
> > > > Nirzari
> >
> > > > On Nov 28, 7:15 pm, Alain Vongsouvanh <[email protected]> wrote:
> >
> > > > > Hello,
> >
> > > > > Please use SSL (https) over non-SSL (http) whenever possible. Also,
> > > make
> > > > > sure that the user issuing the request (e.g the one specified on
> the
> > > > > xoauth_requestor_id query parameter) has write access on the
> domain's
> > > > > shared contacts (it must be an admin user).
> >
> > > > > Also, please make sure to change the "domain" component of the URL
> path
> > > > > with your domain name:
> > > > > https://www.google.com/m8/feeds/contacts/<DOMAIN>/full
> >
> > > > > If that doesn't work, make sure that the scope "
> > >https://www.google.com/m8/feeds" has been authorized for the 2-legged
> > > OAuth
> > > > > consumer key and secret.
> >
> > > > > Best,
> > > > > Alain
> >
> > > > > On Fri, Nov 25, 2011 at 3:36 AM, Nirzari Bhatt
> > > > > <[email protected]>wrote:
> >
> > > > > > Hi,
> >
> > > > > > I am trying synchronize the contacts created in some CRM system
> with
> > > > > > Google Contacts.
> > > > > > i.e. whenever a contact is getting added/deleted/modified in CRM
> it
> > > > > > should get reflected in GoogleContacts. I am using two legged
> > > > > > authentication for the same.
> >
> > > > > > I was able to achieve addContact and UpdateContact functionality.
> >
> > > > > > But when I am trying to delete a contact (i.e. Domain shared
> contact)
> > > > > > from Google its throws following exception.
> >
> > > > > > java.lang.NullPointerException: No authentication header
> information
> > > > > > at
> >
> > >
> com.google.gdata.util.AuthenticationException.initFromAuthHeader(AuthenticationException.java:
> > > > > > 96)
> > > > > > at
> >
> > >
> com.google.gdata.util.AuthenticationException.<init>(AuthenticationException.java:
> > > > > > 67)
> > > > > > at
> >
> > >
> com.google.gdata.client.http.HttpGDataRequest.handleErrorResponse(HttpGDataRequest.java:
> > > > > > 564)
> > > > > > at
> >
> > >
> com.google.gdata.client.http.GoogleGDataRequest.handleErrorResponse(GoogleGDataRequest.java:
> > > > > > 543)
> > > > > > at
> >
> > >
> com.google.gdata.client.http.HttpGDataRequest.checkResponse(HttpGDataRequest.java:
> > > > > > 536)
> > > > > > at
> >
> > >
> com.google.gdata.client.http.HttpGDataRequest.execute(HttpGDataRequest.java:
> > > > > > 515)
> > > > > > at
> >
> > >
> com.google.gdata.client.http.GoogleGDataRequest.execute(GoogleGDataRequest.java:
> > > > > > 515)
> > > > > > at
> com.google.gdata.client.Service.delete(Service.java:1560)
> > > > > > at
> > > com.google.gdata.client.GoogleService.delete(GoogleService.java:
> > > > > > 691)
> > > > > > at
> com.google.gdata.data.BaseEntry.delete(BaseEntry.java:647)
> > > > > > at
> >
> > >
> com.visy.connector.synchronizer.impl.ContactSynchronizerImpl.deleteContact(ContactSynchronizerImpl.java:
> > > > > > 160)
> > > > > > at
> com.visy.connector.TestServlet.doGet(TestServlet.java:58)
> > > > > > at
> > > javax.servlet.http.HttpServlet.service(HttpServlet.java:617)
> > > > > > at
> > > javax.servlet.http.HttpServlet.service(HttpServlet.java:717)
> > > > > > at
> > > > > >
> org.mortbay.jetty.servlet.ServletHolder.handle(ServletHolder.java:
> > > > > > 511)
> > > > > > at org.mortbay.jetty.servlet.ServletHandler
> > > > > > $CachedChain.doFilter(ServletHandler.java:1166)
> > > > > > at
> >
> > >
> com.google.appengine.tools.development.HeaderVerificationFilter.doFilter(HeaderVerificationFilter.java:
> > > > > > 35)
> > > > > > at org.mortbay.jetty.servlet.ServletHandler
> > > > > > $CachedChain.doFilter(ServletHandler.java:1157)
> > > > > > at
> >
> > >
> com.google.appengine.api.blobstore.dev.ServeBlobFilter.doFilter(ServeBlobFilter.java:
> > > > > > 58)
> > > > > > at org.mortbay.jetty.servlet.ServletHandler
> > > > > > $CachedChain.doFilter(ServletHandler.java:1157)
> > > > > > at
> >
> > >
> com.google.apphosting.utils.servlet.TransactionCleanupFilter.doFilter(TransactionCleanupFilter.java:
> > > > > > 43)
> > > > > > at org.mortbay.jetty.servlet.ServletHandler
> > > > > > $CachedChain.doFilter(ServletHandler.java:1157)
> > > > > > at
> >
> > >
> com.google.appengine.tools.development.StaticFileFilter.doFilter(StaticFileFilter.java:
> > > > > > 122)
> > > > > > at org.mortbay.jetty.servlet.ServletHandler
> > > > > > $CachedChain.doFilter(ServletHandler.java:1157)
> > > > > > at
> >
> > >
> com.google.appengine.tools.development.BackendServersFilter.doFilter(BackendServersFilter.java:
> > > > > > 97)
> > > > > > at org.mortbay.jetty.servlet.ServletHandler
> > > > > > $CachedChain.doFilter(ServletHandler.java:1157)
> > > > > > at
> > > > > >
> org.mortbay.jetty.servlet.ServletHandler.handle(ServletHandler.java:
> > > > > > 388)
> > > > > > at
> >
> > > org.mortbay.jetty.security.SecurityHandler.handle(SecurityHandler.java:
> > > > > > 216)
> > > > > > at
> > > > > >
> org.mortbay.jetty.servlet.SessionHandler.handle(SessionHandler.java:
> > > > > > 182)
> > > > > > at
> > > > > >
> org.mortbay.jetty.handler.ContextHandler.handle(ContextHandler.java:
> > > > > > 765)
> > > > > > at
> > > org.mortbay.jetty.webapp.WebAppContext.handle(WebAppContext.java:
> > > > > > 418)
> > > > > > at
> >
> > >
> com.google.apphosting.utils.jetty.DevAppEngineWebAppContext.handle(DevAppEngineWebAppContext.java:
> > > > > > 70)
> > > > > > at
> > > > > >
> org.mortbay.jetty.handler.HandlerWrapper.handle(HandlerWrapper.java:
> > > > > > 152)
> > > > > > at
> > > com.google.appengine.tools.development.JettyContainerService
> > > > > > $ApiProxyHandler.handle(JettyContainerService.java:351)
> > > > > > at
> > > > > >
> org.mortbay.jetty.handler.HandlerWrapper.handle(HandlerWrapper.java:
> > > > > > 152)
> > > > > > at org.mortbay.jetty.Server.handle(Server.java:326)
> > > > > > at
> > > > > >
> org.mortbay.jetty.HttpConnection.handleRequest(HttpConnection.java:
> > > > > > 542)
> > > > > > at org.mortbay.jetty.HttpConnection
> > > > > > $RequestHandler.headerComplete(HttpConnection.java:923)
> > > > > > at
> org.mortbay.jetty.HttpParser.parseNext(HttpParser.java:547)
> > > > > > at
> > > org.mortbay.jetty.HttpParser.parseAvailable(HttpParser.java:212)
> > > > > > at
> > > org.mortbay.jetty.HttpConnection.handle(HttpConnection.java:404)
> > > > > > at
> >
> > >
> org.mortbay.io.nio.SelectChannelEndPoint.run(SelectChannelEndPoint.java:
> > > > > > 409)
> > > > > > at org.mortbay.thread.QueuedThreadPool
> > > > > > $PoolThread.run(QueuedThreadPool.java:582)
> >
> > > > > > Below is the code I am using for deleteContact.
> >
> > > > > > //For Two legged Authentication
> > > > > > GoogleOAuthParameters oauthParameters = new
> GoogleOAuthParameters();
> > > > > > oauthParameters.setScope(Scope);
> > > > > > oauthParameters.setOAuthConsumerKey(ConsumerKey);
> > > > > > oauthParameters.setOAuthConsumerSecret(secret);
> > > > > > OAuthSigner signer = new OAuthHmacSha1Signer();
> >
> > > > > > ContactsService myService = new ContactsService(serviceName);
> > > > > > myService.setOAuthCredentials(oauthParameters, signer);
> > > > > > String FEED_URL =
> http://www.google.com/m8/feeds/contacts/domain/full
> > > ;
> > > > > > String urlStr = FEED_URL + "/" + contactId +
> "?xoauth_requestor_id="
> > > +
> > > > > > domainAdminEmail;
> > > > > > contact = myService.getEntry(new URL(urlStr), ContactEntry.class,
> > > > > > contactId);
> > > > > > contact.delete();
> >
> > > > > > Kindly help me out to figure out what might have gone wrong with
> the
> > > > > > code.
> >
> > > > > > Regards,
> > > > > > Nirzari
> >
> > > > > > --
> > > > > > You received this message because you are subscribed to the
> Google
> > > > > > Groups "Google Contacts, Shared Contacts and User Profiles 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://code.google.com/apis/contacts/community/forum.html
> >
> > > > > --
> > > > > Alain Vongsouvanh | Developer Programs Engineer- Hide quoted text -
> >
> > > > > - Show quoted text -- Hide quoted text -
> >
> > > > - Show quoted text -
> >
> > > --
> > > You received this message because you are subscribed to the Google
> > > Groups "Google Contacts, Shared Contacts and User Profiles APIs" group.
> > > To post to this group, send email to
> > > [email protected]
> > > To unsubscribe from this group, send email to
> > > [email protected]
> > > For more- Hide quoted text -
> >
> > - Show quoted text -
>
> --
> You received this message because you are subscribed to the Google
> Groups "Google Contacts, Shared Contacts and User Profiles 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://code.google.com/apis/contacts/community/forum.html
>
--
Alain Vongsouvanh | Developer Programs Engineer
--
You received this message because you are subscribed to the Google
Groups "Google Contacts, Shared Contacts and User Profiles 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://code.google.com/apis/contacts/community/forum.html