It looks good to me! Of course, you should add more information to the
contact such as a name at least :-).

What you can try to do to make sure that the contact has been created is to
get the contact's self link:

       returnContactEntry.getSelfLink().getHref(); // Returns a string.

And send a 'GET' request to this URL. If successful, that should return the
contact you just created.

       ContactEntry createdContactEntry =
myService.getEntry(newURL(returnContactEntry.getSelfLink().getHref()),
ContactEntry.
class);

I hope this helped!
Best,
Alain

On Tue, May 24, 2011 at 11:33 AM, Jake L. <[email protected]> wrote:

> Hi there,
>
> Here is what my code ended up like:
>
> //Code beings here
>
> *
>
> public
> *
>
> *static* *void* main(String[] args) *throws* ServiceException, IOException
> {
>
> // *TODO* Auto-generated method stub
>
>  ContactsService myService =
>
> *new* ContactsService("exampleCo-exampleApp-1");
>
> myService.setHeader(
>
> "Authorization",<auth code here>);
>
> myService.setUserCredentials(<username/email>, <password>);
>
> ContactEntry returnContactEntry = createContact(myService,<email>);
>
> System.out.println(returnContactEntry);
>
> }
>
> *public* *static* ContactEntry createContact(ContactsService myService,
> String email) *throws* ServiceException, IOException {
>
> ContactEntry contact =
>
> *new* ContactEntry();
>
> Name name =
>
> *new* Name();
>
> name.setFullName(
>
> *null*);
>
> contact.setName(name);
>
>  Email primaryMail =
>
> *new* Email();
>
> primaryMail.setAddress(email);
>
> primaryMail.setRel(
>
> "http://schemas.google.com/g/2005#work";);
>
> primaryMail.setPrimary(
>
> *true*);
>
> contact.addEmailAddress(primaryMail);
>
>  URL postUrl =
>
> *new* URL("https://www.google.com/m8/feeds/contacts/<domain>/full");
>
> *return* myService.insert(postUrl, contact);
>
> }
>
> //Code ends here
>
> And I received a response that looked something like {contactentry + yada
> yada + some id}
>
> I believe that means it was successful in creating the shared contact,
> correct? I did that at 8 am so I will check if it autocompletes the contact
> that I added since it does take 24 hours it says. I will add more to the
> contact information obviously, this was just a test. But does everything
> look ok?
>
> Thanks,
> Jake
>
> --
> 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

-- 
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

Reply via email to