Bug uploading photo for recently created contact.

53 views
Skip to first unread message

martinlong1978

unread,
Dec 16, 2009, 5:37:09 PM12/16/09
to Google Contacts API
I'm using the .NET api now, although I've seen exactly the same
through the Java API, so it would suggest this is a server issue.

When I create a contact there is some kind of race condition, meaning
that _sometimes_ (about 1 in 3) I cannot upload an image for that
contact.

To create the contact:

Uri feedUri = new Uri
(ContactsQuery.CreateContactsUri("default")); // This appears to be
redundent
Feed<Contact> feed = cr.GetContacts();
entry = cr.Insert(feed, entry);
updatePicture();


To upload the photo:

// I've tried up to a 1 min delay before this.
entry = cr.Update(entry);
Console.WriteLine(entry.PhotoUri);
cr.SetPhoto(entry, photoStream);




I get a GDataRequestException:

{"Execution of request failed:
http://www.google.com/m8/feeds/photos/media/test...@longhome.co.uk/20d591310a37df9d"}


{"The remote server returned an error: (404) Not Found."}

However, when I query the feed, it's there, I get:

<entry>
<id>http://www.google.com/m8/feeds/contacts/testuser%40longhome.co.uk/
base/20d591310a37df9d</id>
<updated>2009-12-16T22:28:40.737Z</updated>
<category scheme='http://schemas.google.com/g/2005#kind' term='http://
schemas.google.com/contact/2008#contact'/>
<title type='text'>xxxxxxx</title>
<content type='text'></content>
<link rel='http://schemas.google.com/contacts/2008/rel#edit-photo'
type='image/*' href='http://www.google.com/m8/feeds/photos/media/
testuser%40longhome.co.uk/20d591310a37df9d/1B2M2Y8AsgTpgAmY7PhCfg'/>
<link rel='self' type='application/atom+xml' href='http://
www.google.com/m8/feeds/contacts/testuser%40longhome.co.uk/full/20d591310a37df9d'/>
<link rel='edit' type='application/atom+xml' href='http://
www.google.com/m8/feeds/contacts/testuser%40longhome.co.uk/full/20d591310a37df9d/1261002520737000'/>
<gd:phoneNumber rel='http://schemas.google.com/g/2005#mobile'>+
+44xxxxxxxxx</gd:phoneNumber>
</entry>

dflorey

unread,
Dec 17, 2009, 5:00:36 AM12/17/09
to Google Contacts API
See:

http://groups.google.com/group/google-contacts-api/browse_thread/thread/8a64144a537c8668/90e7d568e0f1c9f7?lnk=gst&q=photo#90e7d568e0f1c9f7

On Dec 16, 11:37 pm, martinlong1978 <mar...@longhome.co.uk> wrote:
> I'm using the .NET api now, although I've seen exactly the same
> through the Java API, so it would suggest this is a server issue.
>
> When I create a contact there is some kind of race condition, meaning
> that _sometimes_ (about 1 in 3) I cannot upload an image for that
> contact.
>
> To create the contact:
>
>                     Uri feedUri = new Uri
> (ContactsQuery.CreateContactsUri("default")); // This appears to be
> redundent
>                     Feed<Contact> feed = cr.GetContacts();
>                     entry = cr.Insert(feed, entry);
>                     updatePicture();
>
> To upload the photo:
>
>                         // I've tried up to a 1 min delay before this.
>                         entry = cr.Update(entry);
>                         Console.WriteLine(entry.PhotoUri);
>                         cr.SetPhoto(entry, photoStream);
>
> I get a GDataRequestException:
>
> {"Execution of request failed:

> http://www.google.com/m8/feeds/photos/media/testu...@longhome.co.uk/20d591310a37df9d"}


>
> {"The remote server returned an error: (404) Not Found."}
>
> However, when I query the feed, it's there, I get:
>
> <entry>
> <id>http://www.google.com/m8/feeds/contacts/testuser%40longhome.co.uk/
> base/20d591310a37df9d</id>
> <updated>2009-12-16T22:28:40.737Z</updated>
> <category scheme='http://schemas.google.com/g/2005#kind'term='http://
> schemas.google.com/contact/2008#contact'/>
> <title type='text'>xxxxxxx</title>
> <content type='text'></content>
> <link rel='http://schemas.google.com/contacts/2008/rel#edit-photo'
> type='image/*' href='http://www.google.com/m8/feeds/photos/media/
> testuser%40longhome.co.uk/20d591310a37df9d/1B2M2Y8AsgTpgAmY7PhCfg'/>

> <link rel='self' type='application/atom+xml' href='http://www.google.com/m8/feeds/contacts/testuser%40longhome.co.uk/full/20d59...>
> <link rel='edit' type='application/atom+xml' href='http://www.google.com/m8/feeds/contacts/testuser%40longhome.co.uk/full/20d59...>

martinlong1978

unread,
Dec 17, 2009, 5:21:08 AM12/17/09
to Google Contacts API
Thanks Daniel.

Slightly different circumstances, as my is a new contact, not an
updated one, but it looks like the same underlying issue.
Unfortunately I cannot wait for an ETag change, because the contact is
new - I can't see the ETag updating once the contact is created.
Waiting for 1 minute would mean it could take 2 hours to sync 120
contacts, unless I set up a workerthread to upload the pictures - God
know what race conditions I'll see then.

"Check the new ETag, wait around 1 minute, and retry few times if it
fails" - OUCH! I hope this is fixed soon.

Martin

On Dec 17, 10:00 am, dflorey <daniel.flo...@gmail.com> wrote:
> See:
>
> http://groups.google.com/group/google-contacts-api/browse_thread/thre...

> > <link rel='self' type='application/atom+xml' href='http://www.google.com/m8/feeds/contacts/testuser%40longhome.co.uk/ful......>
> > <link rel='edit' type='application/atom+xml' href='http://www.google.com/m8/feeds/contacts/testuser%40longhome.co.uk/ful......>

martinlong1978

unread,
Dec 17, 2009, 4:51:12 PM12/17/09
to Google Contacts API
I just tried again... repeatedly for 10 minutes, starting 1 second
apart, increasing to 30 seconds apart. I gave up in the end. This is
still failing. Once a photo fails to upload for a contact, it seems to
fail consistently for every subsequent attempt.

Julian (Google)

unread,
Dec 18, 2009, 12:07:13 PM12/18/09
to Google Contacts API
Hi Martin,

A good strategy is to create all the contacts and store the photo URLs
during the creation process, then upload all the photos after all
contacts have been created. Please try that and let us know how it
goes.

Cheers,
Julian

Martin Long

unread,
Dec 18, 2009, 12:34:07 PM12/18/09
to google-co...@googlegroups.com
I'll give that a go... Of course, when there's only one contact to
sync, then the effect will be the same.

Interestingly last night when I tried the separate thread I was
getting a lot of ' precondition failed' issues. I'll report back when
I get the chance.


Martin

Sent from my iPhone

> --
>
> You received this message because you are subscribed to the Google
> Groups "Google Contacts API" group.
> To post to this group, send email to google-co...@googlegroups.com
> .
> To unsubscribe from this group, send email to google-contacts...@googlegroups.com
> .
> For more options, visit this group at http://groups.google.com/group/google-contacts-api?hl=en
> .
>
>

martinlong1978

unread,
Dec 20, 2009, 11:40:31 AM12/20/09
to Google Contacts API
Ok... I've abandoned trying to upload a photo in this direction. I was
getting "precondition failed" and all sorts. I think this area of the
API needs some attention.

dflorey

unread,
Dec 21, 2009, 1:11:54 PM12/21/09
to Google Contacts API
+1

It should be possible to update/create a contact with both contact data
+photo.
It's really a mess to schedule the photo upload especially when
running on app engine where you cannot schedule tasks dynamically.

Long, Martin

unread,
Dec 21, 2009, 1:23:23 PM12/21/09
to google-co...@googlegroups.com
I can kind of understand the design. The Java / C# APIs just wrap the protocol, and it wouldn't be practical including a BLOB in the XML, when really the photo is just a link to an uploadable object. However, the protocol needs to be transactional. To have a situation where you have to wait an indeterminate amount of time between operation seems ridiculous, although possibly unavoidable in a distributed system. 

Anyway, it doesn't work as it stands - but I guess it's not up to us to do the design ;-)


martinlong1978

unread,
Dec 23, 2009, 1:34:04 PM12/23/09
to Google Contacts API
It's
Reply all
Reply to author
Forward
0 new messages