I am trying to add a contact to a group in google contacts. When I try it in Google's "OAuth 2.0 playground" it works, but from my web-application, with exactly the same headers, method of posting and body, I get "error 400: bad request".
This is my code (php) :
$contact = '<?xml version="1.0"?>
<atom:entry xmlns:atom="http://www.w3.org/2005/Atom" xmlns:gd="http://schemas.google.com/g/2005">
<gd:name> <gd:fullName>Jack Frost</gd:fullName> </gd:name>
<gd:email address="jack.frost@example.com" rel="http://schemas.google.com/g/2005#home"/>
<gd:organization rel="http://schemas.google.com/g/2005#work">
<gd:orgName>Winter Inc.</gd:orgName> </gd:organization>
<gd:phoneNumber rel="http://schemas.google.com/g/2005#home"> (206)555-1213 </gd:phoneNumber>
<gContact:groupMembershipInfo deleted="false" href="http://www.google.com/m8/feeds/groups/MY_EMAIL@gmail.com/base/MY_GROUP_ID"/>
</atom:entry>';
$url = 'https://www.google.com/m8/feeds/contacts/MY_EMAIL@gmail.com/full/';
$method= 'POST';
$headers = ["Host" => "www.google.com", "Gdata-version" => "3.0","Content-length" => strlen($contact), "Content-type" => "application/atom+xml"];
$result = $googleService->request($url,$method,$contact,$headers);
When I leave out the groupMembershipInfo bit, it works.
Joachim