gdata google contacts question, cant update contact

classic Classic list List threaded Threaded
8 messages Options
Reply | Threaded
Open this post in threaded view
|

gdata google contacts question, cant update contact

deltatech
I am able to get lists of contacts and create contacts but I can not update a contact using the examples provided..  I always get this error...

Expected response code 200, got 403 If-Match or If-None-Match header or entry etag attribute required

I am using the exact code which I have seen posted in many places, can anyone tell me what I am doing wrong?  

I get the contact like this, which works fine with no errors.

$query = new Zend_Gdata_Query($id);
$entry = $gdata->getEntry($query);

After examining the data in entry, I can see it is valid data.  Then without modifying the data, I put it back like this..

$entryResult = $gdata->updateEntry($xml->saveXML(),  $entry->getEditLink()->href);

And that is where the error message comes up.    Why would that last line give me this error?

Expected response code 200, got 403 If-Match or If-None-Match header or entry etag attribute required

Reply | Threaded
Open this post in threaded view
|

Re: gdata google contacts question, cant update contact

Trevor Johns-2
The problem here is that in GData v2, versioning is done using HTTP ETags,
rather than as part of the URL. So, when you do this:

$gdata->updateEntry($xml->saveXML(), $entry->getEditLink()->href);


you loose the ETag data that was previously associated with the entry. This
would have worked in GData v1, which would explain the sample code you found
online.

You should just be able to call:

$entry->save();


and have things work.

--
Trevor Johns
Developer Programs Engineer, Android
http://developer.android.com





On Fri, May 20, 2011 at 4:58 PM, deltatech
<[hidden email]>wrote:

> I am able to get lists of contacts and create contacts but I can not update
> a
> contact using the examples provided..  I always get this error...
>
> Expected response code 200, got 403 If-Match or If-None-Match header or
> entry etag attribute required
>
> I am using the exact code which I have seen posted in many places, can
> anyone tell me what I am doing wrong?
>
> I get the contact like this, which works fine with no errors.
>
> $query = new Zend_Gdata_Query($id);
> $entry = $gdata->getEntry($query);
>
> After examining the data in entry, I can see it is valid data.  Then
> without
> modifying the data, I put it back like this..
>
> $entryResult = $gdata->updateEntry($xml->saveXML(),
> $entry->getEditLink()->href);
>
> And that is where the error message comes up.    Why would that last line
> give me this error?
>
> Expected response code 200, got 403 If-Match or If-None-Match header or
> entry etag attribute required
>
>
>
> --
> View this message in context:
> http://zend-framework-community.634137.n4.nabble.com/gdata-google-contacts-question-cant-update-contact-tp3539863p3539863.html
> Sent from the Zend gdata mailing list archive at Nabble.com.
>
> --
> List: [hidden email]
> Info: http://framework.zend.com/archives
> Unsubscribe: [hidden email]
>
>
>
Reply | Threaded
Open this post in threaded view
|

Re: gdata google contacts question, cant update contact

deltatech
 

That fixed the updating.. Is there a similar fix for deleting? The
only example code I have seen is old and I suspect I am using a lot of
old methods. This gives the same error.

$client =
Zend_Gdata_ClientLogin::getHttpClient( $user, $pass,
'cp');
$client->setHeaders('If-Match: *');
$gdata = new
Zend_Gdata($client);
$gdata->setMajorProtocolVersion(3);
$gdata->delete($id);


I found an article with a modification to App.php that fixes this but
I would rather not have to modify the core Zend code.

On Sun, 22 May
2011 23:43:42 -0700, Trevor Johns wrote:

> The problem here is that in
GData v2, versioning is done using HTTP ETags, rather than as part of
the URL. So, when you do this:
>
>>
$gdata->updateEntry($xml->saveXML(), $entry->getEditLink()->href);
>
>
you loose the ETag data that was previously associated with the entry.
This would have worked in GData v1, which would explain the sample code
you found online.
> You should just be able to call:
>
>>
$entry->save();
>
> and have things work.
>
> --
> Trevor Johns
>
Developer Programs Engineer, Android
> http://developer.android.com
[5]
>
> On Fri, May 20, 2011 at 4:58 PM, deltatech wrote:
> I am able
to get lists of contacts and create contacts but I can not update a
>
contact using the examples pro
>
>> h header or
>> entry etag attribute
required
>>
>> I am using the exact code which I have seen posted in
many places, can
>> anyone tell me what I am doing wrong?
>>
>> I get
the contact like this, which works fine with no errors.
>>
>> $query =
new Zend_Gdata_Query($id);
>> $entry = $gdata->getEntry($query);
>>
>>
After examining the data in entry, I can see it is valid data. Then
without
>> modifying the data, I put it back like this..
>>
>>
$entryResult = $gdata->updateEntry($xml->saveXML(),
>>
$entry->getEditLink()->href);
>>
>> And that is where the error message
comes up. Why would that last line
>> give me this error?
>>
>>
Expected response code 200, got 403 If-Match or If-None-Match header
or
>> entry etag attribute required
>>
>> --
>> View this message in
context:
http://zend-framework-community.634137.n4.nabble.com/gdata-google-contacts-question-cant-update-contact-tp3539863p3539863.html
[1]
>> Sent from the Zend gdata mailing list archive at Nabble.com.
>>

>> --
>> List: [hidden email] [2]
>> Info:
http://framework.zend.com/archives [3]
>> Unsubscribe:
[hidden email] [4]
 

Links:
------
[1]
http://zend-framework-community.634137.n4.nabble.com/gdata-google-contacts-question-cant-update-contact-tp3539863p3539863.html
[2]
mailto:[hidden email]
[3]
http://framework.zend.com/archives
[4]
mailto:[hidden email]
[5]
http://developer.android.com
[6] mailto:[hidden email]
Reply | Threaded
Open this post in threaded view
|

Re: gdata google contacts question, cant update contact

Trevor Johns-2
Have you tried calling $entry->delete()?

--
Trevor Johns
Developer Programs Engineer, Android
http://developer.android.com





On Mon, May 23, 2011 at 1:03 PM, Les Fenison <[hidden email]
> wrote:

>  That fixed the updating.. Is there a similar fix for deleting?  The only
> example code I have seen is old and I suspect I am using a lot of old
> methods.  This gives the same error.
>
> $client = Zend_Gdata_ClientLogin::getHttpClient( $user, $pass, 'cp');
> $client->setHeaders('If-Match: *');
> $gdata = new Zend_Gdata($client);
> $gdata->setMajorProtocolVersion(3);
> $gdata->delete($id);
>
> I found an article with a modification to App.php that fixes this but I
> would rather not have to modify the core Zend code.
>
>
>
> On Sun, 22 May 2011 23:43:42 -0700, Trevor Johns wrote:
>
> The problem here is that in GData v2, versioning is done using HTTP ETags,
> rather than as part of the URL. So, when you do this:
>
> $gdata->updateEntry($xml->saveXML(), $entry->getEditLink()->href);
>
>  you loose the ETag data that was previously associated with the entry.
> This would have worked in GData v1, which would explain the sample code you
> found online.
> You should just be able to call:
>
>  $entry->save();
>
>  and have things work.
>
> --
> Trevor Johns
> Developer Programs Engineer, Android
> http://developer.android.com
>
>
>
>
>
> On Fri, May 20, 2011 at 4:58 PM, deltatech <[hidden email]
> > wrote:
>
>> I am able to get lists of contacts and create contacts but I can not
>> update a
>> contact using the examples provided..  I always get this error...
>>
>> Expected response code 200, got 403 If-Match or If-None-Match header or
>> entry etag attribute required
>>
>> I am using the exact code which I have seen posted in many places, can
>> anyone tell me what I am doing wrong?
>>
>> I get the contact like this, which works fine with no errors.
>>
>> $query = new Zend_Gdata_Query($id);
>> $entry = $gdata->getEntry($query);
>>
>> After examining the data in entry, I can see it is valid data.  Then
>> without
>> modifying the data, I put it back like this..
>>
>> $entryResult = $gdata->updateEntry($xml->saveXML(),
>> $entry->getEditLink()->href);
>>
>> And that is where the error message comes up.    Why would that last line
>> give me this error?
>>
>> Expected response code 200, got 403 If-Match or If-None-Match header or
>> entry etag attribute required
>>
>>
>>
>> --
>> View this message in context:
>> http://zend-framework-community.634137.n4.nabble.com/gdata-google-contacts-question-cant-update-contact-tp3539863p3539863.html
>> Sent from the Zend gdata mailing list archive at Nabble.com.
>>
>> --
>> List: [hidden email]
>> Info: http://framework.zend.com/archives
>> Unsubscribe: [hidden email]
>>
>>
>>
Reply | Threaded
Open this post in threaded view
|

Re: gdata google contacts question, cant update contact

deltatech
 

Yes, i thought of that but, it doesn't delete and doesn't throw an
exception either. I tried this...

$client =
Zend_Gdata_ClientLogin::getHttpClient( $user, $pass,
'cp');
$client->setHeaders('If-Match: *');
$gdata = new
Zend_Gdata($client);
$gdata->setMajorProtocolVersion(3);

$entry =
$gdata->getEntry($id);
$entry->delete();

On Mon, 23 May 2011 14:14:45
-0700, Trevor Johns wrote:

> Have you tried calling $entry->delete()?

>
> --
> Trevor Johns
> Developer Programs Engineer, Android
>
http://developer.android.com [1]
 

Links:
------
[1]
http://developer.android.com
Reply | Threaded
Open this post in threaded view
|

Re: gdata google contacts question, cant update contact

Trevor Johns-3
You shouldn't need to call setHeaders() if you're calling delete on an entry.

I don't know why you wouldn't be getting an exception. That's very strange. :(

I'd need to see a packet capture to see what's going on here. It's also possible you're running into problems because we don't actually support the Google Contacts API yet.
Trevor Johns | Developer Programs Engineer | Android Developer Relations | developer.android.com
On Monday, May 23, 2011 at 2:27 PM, Les Fenison wrote:

>
>
> Yes, i thought of that but, it doesn't delete and doesn't throw an
> exception either. I tried this...
>
> $client =
> Zend_Gdata_ClientLogin::getHttpClient( $user, $pass,
> 'cp');
> $client->setHeaders('If-Match: *');
> $gdata = new
> Zend_Gdata($client);
> $gdata->setMajorProtocolVersion(3);
>
> $entry =
> $gdata->getEntry($id);
> $entry->delete();
>
> On Mon, 23 May 2011 14:14:45
> -0700, Trevor Johns wrote:
>
> > Have you tried calling $entry->delete()?
>
> >
> > --
> > Trevor Johns
> > Developer Programs Engineer, Android
> http://developer.android.com [1]
>
>
> Links:
> ------
> [1]
> http://developer.android.com
>
Reply | Threaded
Open this post in threaded view
|

Re: gdata google contacts question, cant update contact

deltatech
 

I have never been able to get $entry->save() to work. But I was
able to make it work like this...

$extra_header =
array('If-Match'=>'*');
$entryResult =
$this->gdata->updateEntry($doc->saveXML(),$edit_id,null,$extra_header);


I have never been able to get delete to work on version 3. Only with
version 1 like this...


$this->gdata->setMajorProtocolVersion(1);
$query = new
Zend_Gdata_Query($id);
$entry =
$this->gdata->getEntry($query);
$entry->delete($id);

I found another
method of deleting using version 3 but it requires a modification to the
Zend code and since other people will be using my code, I decided that
modiifying Zend was a bad idea.

On Tue, 24 May 2011 19:59:15 -0700,
Trevor Johns wrote:

> You shouldn't need to call setHeaders() if
you're calling delete on an entry.
> I don't know why you wouldn't be
getting an exception. That's very strange. :(
> I'd need to see a
packet capture to see what's going on here. It's also possible you're
running into problems because we don't actually support the Google
Contacts API yet.
>
> Trevor Johns | Developer Programs Engineer |
Android Developer Relations | developer.android.com [3] On Monday, May
23, 2011 at 2:27 PM, Les Fenison wrote: -->
>
> On Monday, May 23,
2011 at 2:27 PM, Les Fenison wrote:
>
>> Yes, i thought of that but,
it doesn't delete and doesn't throw an
>> exception either. I tried
this...
>>
>> $client =
>> Zend_Gdata_ClientLogin::getHttpClient(
$user, $pass,
>> 'cp');
>> $client->setHeaders('If-Match: *');
>> $gdata
= new
>> Zend_Gdata($client);
>> $gdata->setMajorProtocolVersion(3);
>>

>> $entry =
>> $gdata->getEntry($id);
>> $entry->delete();
>>
>> On
Mon, 23 May 2011 14:14:45
>> -0700, Trevor Johns wrote:
>>
>>> Have
you tried calling $entry->delete()?
>>
>>> --
>>> Trevor Johns
>>>
Developer Programs Engineer, Android
>> http://developer.android.com [1]
[1]
>>
>> Links:
>> ------
>> [1]
>> http://developer.android.com [2]



Links:
------
[1] http://developer.android.com
[2]
http://developer.android.com
[3] http://developer.android.com
Reply | Threaded
Open this post in threaded view
|

Re: gdata google contacts question, cant update contact

Trevor Johns-3
Glad to hear you got it working.

I should warn you that setting If-Match: * disables optimistic concurrency, which could lead to data loss if a contact is edited by two users/clients at the same time. (One of the edits will be discarded and your app won't receive any warning this is happening.)

That may not necessarily be a problem -- it depends on your app.

I think the real fix for all of this will be eventually adding Contacts support.

Trevor Johns | Developer Programs Engineer | Android Developer Relations | developer.android.com
On Tuesday, May 24, 2011 at 8:58 PM, Les Fenison wrote:

> I have never been able to get $entry->save() to work. But I was able to make it work like this...
> $extra_header = array('If-Match'=>'*');
> $entryResult = $this->gdata->updateEntry($doc->saveXML(),$edit_id,null,$extra_header);
> I have never been able to get delete to work on version 3. Only with version 1 like this...
> $this->gdata->setMajorProtocolVersion(1);
> $query = new Zend_Gdata_Query($id);
> $entry = $this->gdata->getEntry($query);
> $entry->delete($id);
> I found another method of deleting using version 3 but it requires a modification to the Zend code and since other people will be using my code, I decided that modiifying Zend was a bad idea.
> On Tue, 24 May 2011 19:59:15 -0700, Trevor Johns wrote:
> > You shouldn't need to call setHeaders() if you're calling delete on an entry.
> > I don't know why you wouldn't be getting an exception. That's very strange. :(
> > I'd need to see a packet capture to see what's going on here. It's also possible you're running into problems because we don't actually support the Google Contacts API yet.
> >
> > Trevor Johns | Developer Programs Engineer | Android Developer Relations | developer.android.com On Monday, May 23, 2011 at 2:27 PM, Les Fenison wrote: -->
> > On Monday, May 23, 2011 at 2:27 PM, Les Fenison wrote:
> > >
> > >
> > > Yes, i thought of that but, it doesn't delete and doesn't throw an
> > > exception either. I tried this...
> > >
> > > $client =
> > > Zend_Gdata_ClientLogin::getHttpClient( $user, $pass,
> > > 'cp');
> > > $client->setHeaders('If-Match: *');
> > > $gdata = new
> > > Zend_Gdata($client);
> > > $gdata->setMajorProtocolVersion(3);
> > >
> > > $entry =
> > > $gdata->getEntry($id);
> > > $entry->delete();
> > >
> > > On Mon, 23 May 2011 14:14:45
> > > -0700, Trevor Johns wrote:
> > >
> > > > Have you tried calling $entry->delete()?
> > > >
> > > > --
> > > > Trevor Johns
> > > > Developer Programs Engineer, Android http://developer.android.com [1]
> > >
> > >
> > > Links:
> > > ------
> > > [1]
> > > http://developer.android.com