some thread duplication here: http://groups.google.com/group/Google-Picasa-Data-API/browse_thread/thread/3c73f78d8004c224#
On Dec 23 2008, 7:41 am, rb <[email protected]> wrote: > Hi, > > I'm using the java lib with Jruby, with success for creating an album, > but not for uploading a picture. > > The code below work fine, but the last line throws this exception and > I don't have a clue. > > Thanks in advance! > > Raphaël > > The exception: > ######### > NativeException: com.google.gdata.util.InvalidEntryException: Bad > Request > from com/google/gdata/client/http/HttpGDataRequest.java:502:in > `handleErrorResponse' > from com/google/gdata/client/http/GoogleGDataRequest.java: > 555:in `handleErrorResponse' > from com/google/gdata/client/http/HttpGDataRequest.java:480:in > `checkResponse' > from com/google/gdata/client/http/HttpGDataRequest.java:459:in > `execute' > from com/google/gdata/client/http/GoogleGDataRequest.java: > 527:in `execute' > from com/google/gdata/client/media/MediaService.java:339:in > `insert' > > My code is this: > ########## > > require 'java' > include_class 'java.io.File' > include_class 'java.net.URL' > include_class 'com.google.gdata.client.photos.PicasawebService' > include_class 'com.google.gdata.data.photos.AlbumEntry' > include_class 'com.google.gdata.data.media.MediaFileSource' > include_class 'com.google.gdata.data.docs.PhotoEntry' > include_class 'com.google.gdata.data.photos.GphotoEntry' > include_class > 'com.google.gdata.client.authn.oauth.GoogleOAuthParameters' > include_class 'com.google.gdata.client.authn.oauth.GoogleOAuthHelper' > include_class 'com.google.gdata.client.authn.oauth.OAuthParameters' > include_class > 'com.google.gdata.client.authn.oauth.OAuthHmacSha1Signer' > include_class 'com.google.gdata.data.PlainTextConstruct' > > #retrieve use access token and associated secret > u=User.find(1) > k=u.services_keys.picasa.access_token > s=u.services_keys.picasa.access_token_secret > > #build oauth > oautp = GoogleOAuthParameters.new() > oautp.setScope('http://picasaweb.google.com/data/') > oautp.setOAuthConsumerKey(::Services['picasa'].key) > oautp.setOAuthConsumerSecret(::Services['picasa'].secret) > oautp.setOAuthToken(k) > oautp.setOAuthTokenSecret(s) > > signer = OAuthHmacSha1Signer.new() > oauthHelper = GoogleOAuthHelper.new(signer); > > myService = PicasawebService.new ("exampleCo-exampleApp-1") > > myService.setOAuthCredentials(oautp, signer) > > #create album > myAlbum = AlbumEntry.new() > > myAlbum.setTitle(PlainTextConstruct.new("My Test")) > myAlbum.setDescription(PlainTextConstruct.new ("My test from the java > gdata api lib")) > > api_prefix="http://picasaweb.google.com/data/feed/api/user/" > feedUrl = api_prefix + "default" > insertedEntry = myService.insert(URL.new(feedUrl), myAlbum) > > #upload file > > album_feed = insertedEntry.getFeed(nil) > album_url = album_feed.get_id > myMedia = MediaFileSource.new( File.new("/home/rb/Pictures/bougies/ > img_6628.jpg"), "image/jpeg") > > #myPhoto = PhotoEntry.new() > myPhoto = GphotoEntry.new() > myPhoto.setTitle(PlainTextConstruct.new("Bougies")) > myPhoto.setMediaSource(myMedia) > #This only works with GPhotoEntry; not PhotoEntry > myPhoto.setDescription(PlainTextConstruct.new("Test de bougies")) > #This doesn't work > #myPhoto.setClient("UploadForMe") > > #this line raises the exception.... > returnedPhoto = myService.insert(URL.new(album_url), myPhoto) --~--~---------~--~----~------------~-------~--~----~ 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 -~----------~----~----~----~------~----~------~--~---
