Note that there are some explanatory texts on larger screens.

plurals
  1. POUpdate/delete Google apps entry - No ETag found
    text
    copied!<p>When trying to update an entry on Google Apps <code>No ETag found</code> is returned.. Adding entries works just fine, but can't neither update or delete entries!?</p> <p>The ETag is added to the header in one of the last lines in the code:</p> <pre><code>$this-&gt;gdata-&gt;updateEntry($doc-&gt;saveXML(), $update_entry-&gt;getEditLink()-&gt;href, null, array('If-Match' =&gt; '*')); </code></pre> <h1>Exception</h1> <pre><code>Expected response code 200, got 409 </code></pre> <h1>Code</h1> <pre><code>private function update_entry($data, $update_entry=null){ $doc = new DOMDocument(); $doc-&gt;formatOutput = true; $entry = $doc-&gt;createElement('atom:entry'); $entry-&gt;setAttributeNS('http://www.w3.org/2000/xmlns/', 'xmlns:atom', 'http://www.w3.org/2005/Atom'); $entry-&gt;setAttributeNS('http://www.w3.org/2000/xmlns/', 'xmlns:gd', 'http://schemas.google.com/g/2005'); $doc-&gt;appendChild($entry); if($update_entry){ preg_match('/^"?([^"]*)"?$/i', $update_entry-&gt;getEtag(), $matches); $etag_value = $matches[1]; $entry-&gt;setAttribute('gd:etag', $etag_value); $id = $doc-&gt;createElement('id', 'http://www.google.com/m8/feeds/contacts/'.$this-&gt;admin_user.'/base/'.$data['alias']); $entry-&gt;appendChild($id); } $name = $doc-&gt;createElement('gd:name'); $entry-&gt;appendChild($name); $fullName = $doc-&gt;createElement('gd:fullName', $data['name']); $name-&gt;appendChild($fullName); if($data['title']){ $org = $doc-&gt;createElement('gd:organization'); $org-&gt;setAttribute('rel' ,'http://schemas.google.com/g/2005#work'); $entry-&gt;appendChild($org); $orgName = $doc-&gt;createElement('gd:orgTitle', $data['title']); $org-&gt;appendChild($orgName); } if($data['email']){ $email = $doc-&gt;createElement('gd:email'); $email-&gt;setAttribute('address', $data['email']); $email-&gt;setAttribute('rel', 'http://schemas.google.com/g/2005#work'); $entry-&gt;appendChild($email); } if($data['phone_work']){ $phone_work = $doc-&gt;createElement('gd:phoneNumber', $data['phone_work']); $phone_work-&gt;setAttribute('rel', 'http://schemas.google.com/g/2005#work'); $entry-&gt;appendChild($phone_work); } if($data['phone_work_mobile']){ $phone_work_mobile = $doc-&gt;createElement('gd:phoneNumber', $data['phone_work_mobile']); $phone_work_mobile-&gt;setAttribute('rel', 'http://schemas.google.com/g/2005#work_mobile'); $entry-&gt;appendChild($phone_work_mobile); } if($update_entry){ echo $doc-&gt;saveXML(); $this-&gt;gdata-&gt;updateEntry($doc-&gt;saveXML(), $update_entry-&gt;getEditLink()-&gt;href, null, array('If-Match' =&gt; $etag_value)); } else{ $this-&gt;gdata-&gt;insertEntry($doc-&gt;saveXML(), 'http://www.google.com/m8/feeds/contacts/'.self::DOMAIN.'/full'); } } </code></pre> <h1>XML</h1> <pre><code>&lt;?xml version="1.0"?&gt; &lt;atom:entry xmlns:atom="http://www.w3.org/2005/Atom" xmlns:gd="http://schemas.google.com/g/2005" gd:etag="CxFbERtcFit7I2Bu"&gt; &lt;id&gt;http://www.google.com/m8/feeds/contacts/admin_user@domain.com/base/alias&lt;/id&gt; &lt;gd:name&gt; &lt;gd:fullName&gt;name&lt;/gd:fullName&gt; &lt;/gd:name&gt; &lt;gd:organization rel="http://schemas.google.com/g/2005#work"&gt; &lt;gd:orgTitle&gt;title&lt;/gd:orgTitle&gt; &lt;/gd:organization&gt; &lt;gd:email address="mail@domain.com" rel="http://schemas.google.com/g/2005#work"/&gt; &lt;gd:phoneNumber rel="http://schemas.google.com/g/2005#work"&gt;22260435&lt;/gd:phoneNumber&gt; &lt;gd:phoneNumber rel="http://schemas.google.com/g/2005#work_mobile"&gt;1112223&lt;/gd:phoneNumber&gt; &lt;/atom:entry&gt; </code></pre>
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload