Bad request uploading photo to PicasaWeb from GAE

1 view
Skip to first unread message

stefano via StackOverflow

unread,
Dec 24, 2014, 9:45:12 AM12/24/14
to google-appengin...@googlegroups.com

I am working on a webapp on Google App Engine with an upload feature on PicasaWeb. I use this code to upload the photo:

myService = new PicasawebService("my-picasa-web-service");
myService.setConnectTimeout(60000);
myService.setReadTimeout(60000);
myService.setUserCredentials(USERNAME, PASSWORD);
PhotoEntry myPhoto = new PhotoEntry();
myPhoto.setClient("myAdminClient");
MediaStreamSource myMedia = new MediaStreamSource(stream, "image/jpeg");
myPhoto.setMediaSource(myMedia);
PhotoEntry returnedPhoto = myService.insert(new URL(albumFeedUrl), myPhoto);

where stream variable is an InputStream with the uploaded file.

This code works if I run it in a standalone client program. But when I run it using GAE th last line raise and exception and I can see this in the log:

com.google.gdata.util.InvalidEntryException: OK
<HTML>
<HEAD>
<TITLE>Bad Request</TITLE>
</HEAD>
<BODY BGCOLOR="#FFFFFF" TEXT="#000000">
<H1>Bad Request</H1>
<H2>Error 400</H2>
</BODY>
</HTML>

at com.google.gdata.client.http.HttpGDataRequest.handleErrorResponse(HttpGDataRequest.java:602)
at com.google.gdata.client.http.GoogleGDataRequest.handleErrorResponse(GoogleGDataRequest.java:564)
at com.google.gdata.client.http.HttpGDataRequest.checkResponse(HttpGDataRequest.java:560)
at com.google.gdata.client.http.HttpGDataRequest.execute(HttpGDataRequest.java:538)
at com.google.gdata.client.http.GoogleGDataRequest.execute(GoogleGDataRequest.java:536)
at com.google.gdata.client.media.MediaService.insert(MediaService.java:400)

Can you help me to fix this error?

How could I get more information about this?

Thanks stefano



Please DO NOT REPLY directly to this email but go to StackOverflow:
http://stackoverflow.com/questions/27259028/bad-request-uploading-photo-to-picasaweb-from-gae

stefano via StackOverflow

unread,
Dec 24, 2014, 12:55:19 PM12/24/14
to google-appengin...@googlegroups.com

I found the issue; it was related to a content type not valid I was using. In my exaqmple I reported "image/jpeg" as parameter of "new MediaStreamSource()" method. In my original code I was using a variable as content type and it was setted in a bad way, for this reason I had the error.



Please DO NOT REPLY directly to this email but go to StackOverflow:
http://stackoverflow.com/questions/27259028/bad-request-uploading-photo-to-picasaweb-from-gae/27640605#27640605
Reply all
Reply to author
Forward
0 new messages