Im trying to generate the post request to create a new shared contact.
Mdata += "<gd:name>"
Mdata += "<gd:givenName>Elizabeth</gd:givenName>"
Mdata += "<gd:familyName>Bennet</gd:familyName>"
Mdata += "<gd:fullName>Elizabeth Bennet</gd:fullName>"
Mdata += "</gd:name>"
Mdata += "<atom:content type='text'>Notes</atom:content>"
Mdata += "primary='true'"
Mdata += "primary='true'>"
Mdata += "</gd:phoneNumber>"
Mdata += "</gd:phoneNumber>"
Mdata += "primary='true'"
Mdata += "<gd:structuredPostalAddress"
Mdata += "primary='true'>"
Mdata += "<gd:city>Mountain View</gd:city>"
Mdata += "<gd:street>1600 Amphitheatre Pkwy</gd:street>"
Mdata += "<gd:region>CA</gd:region>"
Mdata += "<gd:postcode>94043</gd:postcode>"
Mdata += "<gd:country>United States</gd:country>"
Mdata += "<gd:formattedAddress>"
Mdata += "1600 Amphitheatre Pkwy Mountain View"
Mdata += "</gd:formattedAddress>"
Mdata += "</gd:structuredPostalAddress>"
Mdata += "</atom:entry>"
lMdata = (Mdata)
request.add_header('GData-Version', '3.0')
request.add_header('Content-Type', 'application/atom+xml')
request.add_header('Authorization', 'GoogleLogin auth=' + self.login_token)
opener = urllib2.build_opener()
result = opener.open(request).read()
im sending the same sample data given in the api documentation. i make the request after a successfull login and providing the token in the header.
File "C:\Python27\lib\urllib2.py", line 400, in open
response = meth(req, response)
File "C:\Python27\lib\urllib2.py", line 513, in http_response
'http', request, response, code, msg, hdrs)
File "C:\Python27\lib\urllib2.py", line 438, in error
return self._call_chain(*args)
File "C:\Python27\lib\urllib2.py", line 372, in _call_chain
result = func(*args)
File "C:\Python27\lib\urllib2.py", line 521, in http_error_default
raise HTTPError(req.get_full_url(), code, msg, hdrs, fp)
HTTPError: HTTP Error 400: Bad Request
maybe the issue is sending xml data as body in a post request. can anyone there provide me sample of how to post xml to google apps api please.
Thanks for your help