> > I have accessed picasa by combining Oauth2 and old api > > //client_secrets.json file that i got from google developers console when i registered my app UserCredential credential; using (var stream = new FileStream("client_secrets.json", FileMode.Open, FileAccess.Read)) { credential = await GoogleWebAuthorizationBroker.AuthorizeAsync( GoogleClientSecrets.Load(stream).Secrets, new[] { "https://picasaweb.google.com/data/" }, "user_id from client_secrets.json file", CancellationToken.None); }
GAuthSubRequestFactory authFactory = new GAuthSubRequestFactory("lh2", "my-app"); authFactory.Token = credential.Token.AccessToken; PicasaService service = new PicasaService(authFactory.ApplicationName); service.RequestFactory = authFactory; AlbumQuery query = new AlbumQuery(PicasaQuery.CreatePicasaUri("default")); PicasaFeed feed = service.Query(query); string uri = ""; foreach (PicasaEntry entry in feed.Entries) { ..... This code works fine. Hope it will help somebody. I`ve spen 2 days on that. среда, 20 мая 2015 г., 17:16:53 UTC+3 пользователь Prerana Polekar написал: > > 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 google-picasa-data-api+unsubscr...@googlegroups.com. To post to this group, send email to google-picasa-data-api@googlegroups.com. Visit this group at http://groups.google.com/group/google-picasa-data-api. For more options, visit https://groups.google.com/d/optout.