4 messages in com.googlegroups.google-picasa-data-apiProblem inserting PhotoEntry in album...
FromSent OnAttachments
jam4205 Apr 2007 17:19 
Sven06 Apr 2007 09:49 
jam4206 Apr 2007 10:00 
jam4206 Apr 2007 13:08 
Subject:Problem inserting PhotoEntry in album feed
From:jam42 (john@gmail.com)
Date:04/05/2007 05:19:43 PM
List:com.googlegroups.google-picasa-data-api

[feedback: It would help clear up some confusion if there were a comment in the code samples explaining how to determine the post URL for insert operations. Or at least references back to the overview of Atom and feeds.]

I read through this thread

http://groups.google.com/group/Google-Picasa-Data-API/browse_thread/thread/2cfe380585291db6

and found Kyle's advice for determining an album's feed URL (Hi Kyle, small world!). I give the following URL to a browser:

http://picasaweb.google.com/data/feed/api/user/john.methot?kind=album

and get back and XML file containing the following link for my album (after running the code below, which creates the album in question):

<link rel="http://schemas.google.com/g/2005#feed" type="application/ atom+xml" href="http://picasaweb.google.com/data/feed/api/user/ john.methot/albumid/5050099601765509809" />

If I do this programmatically by getting the AlbumEntry's ID, it seems to be the same as the feed link's href. But when I try to post to that URL (last code line below), I get the output below (InvalidEntryException: Bad Request Invalid Request URI).

Note that I'm creating an album, then trying to immediately get the new album's feed URL and insert a photo. Album creation is working fine.

Thanks for any help.

John

*** begin code ***

AlbumEntry insertedEntry = (AlbumEntry)myService.insert(postUrl, myEntry);

Link albumLink = insertedEntry.getHtmlLink(); System.out.println("Album Link: " + albumLink.getHref()); URL albumLinkURL = new URL(albumLink.getHref());

String albumID = insertedEntry.getId(); System.out.println("Album ID: " + albumID);

URL albumURL = new URL(albumID); System.out.println("Album URL: " + albumURL.toString());

PhotoEntry myPhoto = new PhotoEntry(); myPhoto.setTitle(new PlainTextConstruct("Sunset.jpg")); myPhoto.setDescription(new PlainTextConstruct("Darcy on the beach")); myPhoto.setClient("myClientName"); GregorianCalendar cal = new GregorianCalendar(2004, 4, 21); myPhoto.setTimestamp(cal.getTime());

MediaFileSource myMedia = new MediaFileSource(new File("/temp/ Sunset.jpg"), "image/jpeg"); myPhoto.setMediaSource(myMedia);

PhotoEntry returnedPhoto = (PhotoEntry)myService.insert(albumURL, myPhoto);

*** end code ***

*** begin output ***

Album Link: http://picasaweb.google.com/john.methot/TripToMongolia Album ID:
http://picasaweb.google.com/data/entry/api/user/john.methot/albumid/5050099601765509809 Album URL:
http://picasaweb.google.com/data/entry/api/user/john.methot/albumid/5050099601765509809 com.google.gdata.util.InvalidEntryException: Bad Request Invalid Request URI

at com.google.gdata.client.http.HttpGDataRequest.handleErrorResponse(Unknown Source) at com.google.gdata.client.http.GoogleGDataRequest.handleErrorResponse(Unknown Source) at com.google.gdata.client.http.HttpGDataRequest.checkResponse(Unknown Source) at com.google.gdata.client.http.HttpGDataRequest.execute(Unknown Source) at com.google.gdata.client.http.GoogleGDataRequest.execute(Unknown Source) at com.google.gdata.client.Service.insert(Unknown Source) at com.google.gdata.client.GoogleService.insert(Unknown Source) at LViewToPicasa.createAlbum(LViewToPicasa.java:71) at LViewToPicasa.main(LViewToPicasa.java:103)

*** end output***