Hi Prerana, I'am having the same error from Java.
I create the request exactly as is described in: https://developers.google.com/picasa-web/docs/2.0/developers_guide_protocol#PostPhotos However my result is the same: Server returned HTTP response code: 400 for URL: https://picasaweb.google.com/data/feed/api/user/default/albumid/ABCDEF... And the response text:<HTML> <HEAD> <TITLE>Bad Request</TITLE> </HEAD> <BODY BGCOLOR="#FFFFFF" TEXT="#000000"> <H1>Bad Request</H1> <H2>Error 400</H2> </BODY> </HTML> I tried Posting a photo *without *metadata and it works! Do you have any update on the issue? Greetings! El miércoles, 20 de mayo de 2015, 9:16:53 (UTC-5), Prerana Polekar escribió: > > Hello All, > I am trying to upload a image with metadata using Picasa Web Album Data > API version 2.0 in C#. Its throwing 'Bad Request' error. The error does not > indicate which part in request is missing or where I am going wrong. The > image upload without metadata works perfectly. Following is the code : > > > byte[] image = System.IO.File.ReadAllBytes(fullimagepath); > int imglenth= image.Length; > string rawImgXml="<entry xmlns=\'http://www.w3.org/2005/ > Atom\'>"+"\n"+ > "<title>plz-to-love-realcat.jpg</title>"+"\n"+ > "<summary>Real cat wants attention too</summary>"+"\n" > + > "<category scheme=\"http://schemas.google.com/g/2005# > kind\""+ > "term=\"http://schemas.google.com/photos/2007#photo\"/ > >"+"\n"+ > "</entry>"; > > string data = ""; > data ="\nMedia multipart posting\n"+ > "--P4CpLdIHZpYqNn7\n"+ > "Content-Type: application/atom+xml\n\n"+ > rawImgXml + "\n" > +"--P4CpLdIHZpYqNn7\n" > +"Content-Type: image/jpeg\n\n"+ > "--P4CpLdIHZpYqNn7--"; > > int length=data.Length+imglenth; > > HttpWebRequest request = (HttpWebRequest)WebRequest.Create > ("https://picasaweb.google.com/data/feed/api/user/"+tc.userId+"/albumid/"+ > "6150508893827643953"+"?access_token="+tc.auth_Token); > byte[] bytes; > bytes = System.Text.Encoding.ASCII.GetBytes(data); > request.ContentType = "multipart/related; boundary= > P4CpLdIHZpYqNn7"; > request.ContentLength = length; > request.Headers.Add("GData-Version","2"); > request.Headers.Add("MIME-Version","1.0"); > request.Method = "POST"; > Stream requestStream = request.GetRequestStream(); > requestStream.Write(image, 0, image.Length); > requestStream.Write(bytes, 0, bytes.Length); > requestStream.Close(); > HttpWebResponse response; > response = (HttpWebResponse)request.GetResponse(); > > Stream responseStream = response.GetResponseStream(); > string responseStr = new StreamReader(responseStream). > ReadToEnd(); > > > Where am I going wrong? Instead of attaching the image binary data in the > string named 'data' I am writing it to the stream, is that the culprit? Any > suggestions or directions will be of great help. Thanks a ton in advance! > > -Prerana > > > > > -- You received this message because you are subscribed to the Google Groups "Google Picasa Web Albums API" group. To unsubscribe from this group and stop receiving emails from it, send an email to [email protected]. To post to this group, send email to [email protected]. Visit this group at http://groups.google.com/group/google-picasa-data-api. For more options, visit https://groups.google.com/d/optout.
