Dear Patty, Thanks for your help, I found my mistake which was missing to reset the memory stream location using Seek method
Regards -----Original Message----- From: [email protected] [mailto:[email protected]] On Behalf Of Patty Sent: Friday, June 12, 2009 7:19 PM To: Google Contacts API Subject: [Contacts API] Re: Problem with updating photo of a contact Hi! I up the photo with this code in C # Net: ContactEntry newEntry = new ContactEntry(); newEntry.Title.Text =this.txtNuevoContacto.Text; Uri feedUri = new Uri(ContactsQuery.CreateContactsUri ("default")); ContactEntry createdEntry = (ContactEntry)service.Insert (feedUri, newEntry); System.Drawing.Bitmap Image = new System.Drawing.Bitmap (@"C:\foto.jpg"); System.IO.MemoryStream Memory = new System.IO.MemoryStream (); Image.Save(Memory, System.Drawing.Imaging.ImageFormat.Jpeg); Memory.Seek(0, SeekOrigin.Begin); service.Update(createdEntry.PhotoUri, Memory, "image/ jpeg", null); Greetings. Patty.- On Jun 12, 4:16 am, BeTa <[email protected]> wrote: > Hello everyone, > I'm new to the API and using .Net library (version 2.0), I'm trying to > update a contact picture using SetPhoto method and I always get this > exception: > > Execution of request failed: http://www.google.com/m8/feeds/photos/media/[email protected]/1b6733260c85 758c > > I'm capable of doing other things such as changing name or etc easily. > > here I copy the code I wrote to make this work. > > I'd appreciate your help > > ImageConverter conv = new ImageConverter(); > /// retrieving picture property of my object > and convert it to byte > byte[] res = (byte[])conv.ConvertTo(((Image) > info.GetValue(contact, null)), typeof(byte[])); > MemoryStream str = new MemoryStream(); > str.Write(res, 0, res.Length); > > cr.SetPhoto(item, str); > /// I recieve the error when this method is > called > > Cheers > BT --~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "Google Contacts 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-contacts-api?hl=en -~----------~----~----~----~------~----~------~--~---
