Sorry to bother again. Your previous solution for the gdata library worked like a charm, but I'm trying to get rid of some overhead and doing plain requests. I fixed the URL to point to a picture, I authenticate and then I try the URL for a picture. I.E. url = 'http://picasaweb.google.com/data/media/api/user/vallsdotname/ albumid/5365689932489135537/photoid/5365689989036907650/1' this gives me a Error! Got "409 Conflict" Right, I updated the picture using GData, so my guess is that the version will be 2, so I try again with the url: url = 'http://picasaweb.google.com/data/media/api/user/vallsdotname/ albumid/5365689932489135537/photoid/5365689989036907650/2' but i get the same. ok, I'll keep increasing the version number, but when I try 3 i get Error! Got "400 Bad Request". I think I didn't understand your proposed solution of the retry option on 409. What way should I retrieve the version number? Anyway, the thing is that then I use the gdata library and when I record the session, there are some headers that don't match what the protocol documentation shows. What is the data after the version number (?authkey=Gv1sRgCLDEx9OSxMyCzgE)? It's the 3rd log:
Here are the Http logs. Send: Return Code: 0x00000000 PUT /data/media/api/user/vallsdotname/albumid/5365689932489135537/ photoid/5365689989036907650/2 HTTP/1.1 Host: picasaweb.google.com Accept-Encoding: identity Content-Type: image/jpeg Content-Length: 66993 Authorization: GoogleLogin auth=DQAAAIwAAAAs8MVs5Z6Ede9Sdp5iM- Pm91ElbMbvODKEv0DMqk8RkzDwkCh9Nf1NNnfdUjHcjLSzHkAuWc9Kf3mmj6enkb4vW1BLTmTmT39THURKyOyCa8kiOsAgovofgVOBeQmNCRx4Og0966Obm81I0F0nCr4BzxJqwFAE-94JGHfkYRn_g6h0j2Qx4tE4cgZ2uejdPRQ Send: Return Code: 0x00000000 00000000 FF D8 FF E0 00 10 4A 46 49 46 00 01 01 01 00 60 ......JFIF.....` Send: Return Code: 0x00000000 PUT /data/media/api/user/vallsdotname/albumid/5365689932489135537/ photoid/5365689989036907650/3 HTTP/1.1 Host: picasaweb.google.com Accept-Encoding: identity Content-Type: image/jpeg Content-Length: 66993 Authorization: GoogleLogin auth=DQAAAIoAAAA1V68EloXFPZHFZQHJMuFgdJ2dNBqKJtAEsyzD79GmcM_vSZroxVBvikANuQZRlk4hn9fd8Z5NqsYVGwlB50Kjh0WDeXtMh_afdtnAlA9tZG0AzX9lOFZ- cafeit2j_6Lgl0rBIUSUgo84T9bVr1dXQj9TRcaY8OfozbBmUn7chr9cmFDW26fZZiztaCgCtVM Send: Return Code: 0x00000000 00000000 FF D8 FF E0 00 10 4A 46 49 46 00 01 01 01 00 60 ......JFIF.....` Send: Return Code: 0x00000000 PUT http://picasaweb.google.com/data/media/api/user/vallsdotname/albumid/5365689932489135537/photoid/5365689989036907650/3?authkey=Gv1sRgCLDEx9OSxMyCzgE HTTP/1.1 Accept-Encoding: identity Host: picasaweb.google.com Content-Length: 9474 Content-Type: image/jpeg Authorization: GoogleLogin auth=DQAAAIsAAAAnRTjWtj0r40gP5eiH- C0Y785TOIrWNXtJISJSFlmSbPlOXO1pT6ELOZPIK6IAhS1aQtYYYGzUTiMNcvqQ5EF4_2cxAJyVxJe_7iNWLvNsAppUXEPuxCRqX8h- k6vpf71Z_hNyVV5P0hJ86v-E-QLRwwAaHqEuFVz8FMjDgUXt6PxW5WTh7xAO8MA- bPhtz58 User-Agent: None GData-Python/1.3.3 Send: Return Code: 0x00000000 00000000 FF D8 FF E0 00 10 4A 46 49 46 00 01 01 00 00 01 ......JFIF...... On Aug 10, 4:28 pm, Detlev <[email protected]> wrote: > It seems that you ran into an issue that we haven't found a good > solution for yet: > Our photo storage servers maintain a version number for every photo. > This version gets updated every time the meta data or the binary data > is updated either externally or internally. It is the case that for a > metadata update, that version number gets incremented twice: the first > time when you make your first edit call, the second time when some > asynchronous process that gets triggered has finished and touches the > photo again. For GData calls that unfortunately currently has the > effect, that the updated entry being returned from your first edit > call has the version number incremented by 1. This new version number > is then used by your second request to edit the binary data. > Unfortunately, in the meantime, the photo version has been increased a > second time and so the version you are sending up in you second edit > call does not match the current version anymore and you get a 409 > error.There are two possible workarounds in your case: > A. Update meta data and binary data in a single request after you are > done processing the image: > 1. query current photo entry > 2. apply your meta data edits to the entry (e.g. caption, title aka > filename) > 3. make your UpdatePhoto call > > B. the other option is to build in a retry mechanism based on > receiving a 409: > 1. when an update fails with a version conflict, just retry it using > the most recent photo entry that is being returned with the failure. > You'll have to apply your metadata changes again though. > > On Aug 8, 8:28 am, Josep Valls <[email protected]> wrote: > > > My code is as follows: > > import gdata.photos.service > > import gdata.media > > import gdata.geo > > import atom > > > username = 'vallsdotname' > > email = 'XXX' > > password = 'XXX > > source = 'vallsdotname-albumlist-1' > > filename = 'C:/Users/Valls/Downloads/Desktops/ > > 00660_splash_2560x1600.jpg' > > > pws = gdata.photos.service.PhotosService() > > pws.ClientLogin(username, password) > > albums = pws.GetUserFeed().entry > > photos = pws.GetFeed(albums[0].GetPhotosUri()).entry > > album = albums[0] > > photo = pws.InsertPhotoSimple(album_url, 'New Photo', 'Uploaded using > > the API', filename, content_type='image/jpeg') > > photo = photos[8] > > photo.rotation = gdata.photos.Rotation(text='90') > > photo = pws.UpdatePhotoMetadata(photo) > > # so far so good > > ph = pws.UpdatePhotoBlob(photo, filename) > > # errors > > fh = open(filename, 'rb') > > ph = pws.UpdatePhotoBlob(photo, fh) > > # errors > > > And this is what I captured. Hopefully will be enough. Any advice on > > http monitors? > > > Send: Return Code: 0x00000000 > > PUThttp://picasaweb.google.com/data/media/api/user/vallsdotname/albumid/... > > HTTP/1.1 > > Accept-Encoding: identity > > Host: picasaweb.google.com > > Content-Length: 176489 > > Content-Type: image/jpeg > > Authorization: GoogleLogin > > auth=DQAAAIwAAAAMe34fRcNb3L_9GuxNfNbdk2cfgk886rkmn1PZ9tGBcy1gPTuROvNgbgQi8eqfP_XY5K5WPmSbtw5SmOPm8huMK- > > WQ4oAaRboug_bmtjzHz7JgqkyerDQSdpteFrsWK0CXJZpfpdBghMRT0gLkGMEMVaiSx9lsSMT7DADG8H3HyT7ehSJeW4oIdGiRxA- > > Fcx4 > > User-Agent: None GData-Python/1.3.3 > > > Send: Return Code: 0x00000000 > > 00000000 FF D8 FF E0 00 10 4A 46 49 46 00 01 01 01 00 > > 48 ......JFIF.....H > > [...] > > > Receive: Return Code: 0x00000000 > > <?xml version='1.0' encoding='UTF-8'?><entry xmlns='http://www.w3.org/ > > 2005/Atom' xmlns:exif='http://schemas.google.com/photos/exif/2007' > > xmlns:gphoto='http://schemas.google.com/photos/2007' > > xmlns:media='http://search.yahoo.com/mrss/'><id>http:// > > picasaweb.google.com/data/entry/api/user/vallsdotname/albumid/ > > 5365689932489135537/photoid/5367284203201802034</ > > id><published>2009-08-07T18:03:55.000Z</ > > published><updated>2009-08-08T15:17:16.503Z</updated><category > > scheme='http://schemas.google.com/g/2005#kind'term='http:// > > schemas.google.com/photos/2007#photo'/><title type='text'>New Photo</ > > title><summary type='text'>Uploaded using the API</summary><content > > type='image/jpeg' src='http://lh4.ggpht.com/_vgXOso7OdEA/Snxsi7RorzI/ > > AAAAAAAAB6k/j-KVLIK75LQ/New%20Photo.jpg'/><link rel='http:// > > schemas.google.com/g/2005#feed' type='application/atom+xml' > > href='http://picasaweb.google.com/data/feed/api/user/vallsdotname/ > > albumid/5365689932489135537/photoid/5367284203201802034? > > authkey=Gv1sRgCLDEx9OSxMyCzgE'/><link rel='alternate' type='text/html' > > href='http://picasaweb.google.com/vallsdotname/2009_07_29? > > authkey=Gv1sRgCLDEx9OSxMyCzgE#5367284203201802034'/><link rel='http:// > > schemas.google.com/photos/2007#canonical' type='text/html' > > href='http://picasaweb.google.com/lh/photo/BdP8LrkztXzpxc4vYnpPmg? > > authkey=Gv1sRgCLDEx9OSxMyCzgE'/><link rel='self' type='application/atom > > +xml' href='http://picasaweb.google.com/data/entry/api/u > > Receive: Return Code: 0x00000000 > > ser/vallsdotname/albumid/5365689932489135537/photoid/ > > 5367284203201802034?authkey=Gv1sRgCLDEx9OSxMyCzgE'/><link rel='edit' > > type='application/atom+xml' href='http://picasaweb.google.com/data/ > > entry/api/user/vallsdotname/albumid/5365689932489135537/photoid/ > > 5367284203201802034/32?authkey=Gv1sRgCLDEx9OSxMyCzgE'/><link rel='edit- > > media' type='image/jpeg' href='http://picasaweb.google.com/data/media/ > > api/user/vallsdotname/albumid/5365689932489135537/photoid/ > > 5367284203201802034/32?authkey=Gv1sRgCLDEx9OSxMyCzgE'/><link > > rel='media-edit' type='image/jpeg' href='http://picasaweb.google.com/ > > data/media/api/user/vallsdotname/albumid/5365689932489135537/photoid/ > > 5367284203201802034/32?authkey=Gv1sRgCLDEx9OSxMyCzgE'/><link > > rel='http://schemas.google.com/photos/2007#report'type='text/html' > > href='http://picasaweb.google.com/lh/reportAbuse? > > uname=vallsdotname&aid=5365689932489135537&iid=5367284203201802034'/><gphoto:id>5367284203201802034</gphoto:id><gphoto:version>32</ > > > gphoto:version><gphoto:albumid>5365689932489135537</ > > gphoto:albumid><gphoto:access>private</ > > gphoto:access><gphoto:width>1200</gphoto:width><gphoto:height>1600</ > > gphoto:height><gphoto:size>117066</gphoto:size><gphoto:client/><gphoto:checksum/><gphoto:timestamp>1249668235000</ > > > gphoto:timestamp><gphoto:imageVersion>1961</ > > gphoto:imageVersion><gphoto:commentingEnabled>true</ > > gphoto:commentingEnabled><gphoto:commentCount>1</ > > gphoto:commentCount><exif:tags><exif:imageUniqueID>5e2680042d568e46fdcf7b2ee89f2a7b</ > > exif:imageUniqueID></exif:tags><media:group><media:content url='http:// > > lh4.ggpht.com/_vgXOso7OdEA/Snxsi7RorzI/AAAAAAAAB6k/j-KVLIK75LQ/New > > %20Photo.jpg' height='1600' width='1200' type='image/jpeg' > > medium='image'/><media:credit>josep.vallsva</ > > media:credit><media:description type='plain'>Uploaded using the API</ > > media:description><media:keywords/><media:thumbnail url='http:// > > lh4.ggpht.com/_vgXOso7OdEA/Snxsi7RorzI/AAAAAAAAB6k/j-KVLIK75LQ/s72/New > > %20Photo.jpg' height='72' width='54'/><media:thumbnail url='http:// > > lh4.ggpht.com/_vgXOso7OdEA/Snxsi7RorzI/AAAAAAAAB6k/j-KVLIK75LQ/s144/New > > %20Photo.jpg' height='144' width='108'/><media:thumbnail url='http:// > > lh4.ggpht.com/_vgXOso7OdEA/Snxsi7RorzI/AAAAAAAAB6k/j-KVLIK75LQ/s288/New > > %20Photo.jpg' height='288' width='216'/><media:title type='plain'>New > > Photo</media:title></media:group></entry> > > > Is there a bug somewhere that should be reported? > > I guess I could work around it by generating my own request, in that > > case, it'd be very helpful if you could direct me to some good > > tutorials to start with this. > > > Thanks! > > > On Aug 8, 1:31 am, Detlev <[email protected]> wrote: > > > > This sounds like a version conflict issue. In GData v1, you had to > > > specifiy the current versionid with the edit link. Requesting a photo > > > entry would conveniently add it to the edit link element. In Gdata v2, > > > we no longer support this type of optimistic concurrency. Instead > > > you'll need to take the ETag from the last photo entry response and > > > use it in the If-Match header for your next update request. You can > > > also use a * for the If-Match header to effectively disable any > > > version checking. > > > I am not familiar at all with the Python client library, and am not > > > sure if it even supports v2 already for the Picasa Web API. > > > Can you log the entire HTTP requests and responses (with headers)? > > > This should tell you if you're really sending a v2 GData request or > > > not, and if the library is setting the headers correctly. > > > > On Aug 7, 4:16 pm, Josep Valls <[email protected]> wrote: > > > > > Hi, > > > > > I'd like to do some processing on the images I have posted on Picasa. > > > > I will download them, process them and update the image data. I want > > > > to keep all my albums and all the metadata the pictures already had > > > > when I first uploaded them. > > > > When I try to call UpdatePhotoBlob I get the following exception: > > > > Traceback (most recent call last): > > > > File "..\7.py", line 31, in <module> > > > > ph = pws.UpdatePhotoBlob(photo, filename) > > > > File "c:\python25\Lib\site-packages\gdata\photos\service.py", line > > > > 581, in Upd > > > > atePhotoBlob > > > > raise GooglePhotosException(e.args[0]) > > > > gdata.photos.service.GooglePhotosException: (409, 'Conflict', "<?xml > > > > version='1. > > > > 0' encoding='UTF-8'?><entry xmlns='http://www.w3.org/2005/Atom' > > > > xmlns:exif='http > > > > ://schemas.google.com/photos/exif/2007' xmlns:gphoto='http:// > > > > schemas.google.com/ > > > > photos/2007' xmlns:media='http://search.yahoo.com/mrss/'><id>http:// > > > > picasaweb.go... > > > > > This trace is from gdata 2.0.0. Same exception with 2.0.1. > > > > > What am I doing wrong? > > > > > Thanks! --~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "Google Picasa Web Albums API" 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://groups.google.com/group/Google-Picasa-Data-API?hl=en -~----------~----~----~----~------~----~------~--~---
