Hi.

I'm facing the same problem, I didn't retrieved the contact twice, but
it's giving me the GDataNotModifiedException.

The first time I executed the program, it worked, but after that, it's
impossible to get the photo again.

I'm using VS2008 and a debug compilation.

P.D.: I've solved the problem with a workaround, i'm posting it here
for anyone facing the same problem:

private static byte[] GooglePhoto(ContactEntry contactoGoogle, string
UsuarioGoogle, string PasswordGoogle, string AuthToken)
{
    try
    {
        RequestSettings settings = new RequestSettings("sba-outsync-v1",
UsuarioGoogle, PasswordGoogle);
        settings.AutoPaging = false;
        settings.Maximum = 50000;
        settings.PageSize = 50000;

        ContactsRequest req = new ContactsRequest(settings);

        Contact c = new Contact();
        c.AtomEntry = (AtomEntry)contactoGoogle;

        Stream str = req.GetPhoto(c);

        if (str != null)
        {
            byte[] b = new byte[str.Length];
            str.Read(b, 0, (int)str.Length);

            return b;
        }

        return null;
    }
    catch (GDataNotModifiedException e)
    {
        HttpWebRequest req = (HttpWebRequest)HttpWebRequest.Create
(contactoGoogle.PhotoUri);

        req.Headers.Add("Authorization", "GoogleLogin auth=" + AuthToken);

        HttpWebResponse resp = (HttpWebResponse)req.GetResponse();

        Stream str = resp.GetResponseStream();

        byte[] b = new byte[1024];

        List<byte> buffer = new List<byte>();

        int leido = 0;
        do
        {
            leido = str.Read(b, 0, b.Length);

            if (leido == 1024)
                buffer.AddRange(b);
            else
            {

                byte[] b2 = new byte[leido];
                Array.Copy(b, b2, leido);
                buffer.AddRange(b2);
            }

        } while (leido == 1024);

        b = buffer.ToArray();

        return b;

    }
}

On Jul 15, 8:27 pm, Frank Mantek <[email protected]> wrote:
> so, this is probably not throwing on getting the photo, but on getting  
> the contact again? but if you already have the contact, why don't you  
> use the one you already have?
>
> Frank Mantek
> Google
>
> On Jul 14, 2009, at 10:29 AM, Berto wrote:
>
>
>
> > Hi everyone,
> > I've tried to retrieve photo from a contact with this code, as
> > described on documentation
>
> >            RequestSettings rs = new RequestSettings("Test", "XXX",
> > "XXX");
> >            rs.AutoPaging = true;
> >            ContactsRequest cr = new ContactsRequest(rs);
> >            cr.Settings.Timeout = 0;
> >            Feed<Contact> f = cr.GetContacts();
>
> >            foreach (Contact e in f.Entries)
> >            {
> >                Stream s = cr.GetPhoto(e);
> >            }
>
> >            Console.ReadLine();
>
> > when I execute Stream s = cr.GetPhoto(e) it throws a
> >GDataNotModifiedExceptionbecause contact is already loaded and not
> > modified. How can I retrieve a photo from a contact without a
> > contact :| ?? I don't understand how to do this...
> > Thx
> > Massimo
--~--~---------~--~----~------------~-------~--~----~
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
-~----------~----~----~----~------~----~------~--~---

Reply via email to