i’ve been scratching my head these last few days on that problem so i hope someone can help me because i don’t know where to dig.
As the title says i’m working on a project using omniauth google oauth2 for authentication. This part works fine since the beginning.
Next part is creating contacts in the google contacts api and it doesn’t work.
As the xml/atom to generate is a little heavy i decide to use a xml view and use render_to_string to retrieve it in my controller. As i don’t know a lot about rails i just figured it wolud be cleaner to generate like that. This works fine.
So here is my oauth2 call :
strxml = render_to_string( :partial => 'createInGoogle', :layout => false )
response = access_token.post('/m8/feeds/contacts/default/full', params: {:body => strxml, :header => 'Content-type: application/atom+xml;GData-Version: 3.0'})
When i debug that call i can see the url generated looks like
"https://www.google.com/m8/feeds/contacts/default/full?body=%3Catom%3Aentry+xmlns%3Aatom%3D%27http%3A%2F%2Fwww.w3.org%2F2005%2FAtom%27+xmlns%3Agd%3D%27http%3A%2F%2Fschemas.google.com%2Fg%2F2005%27%3E%0A%3Catom%3Acategory+scheme%3D%27http%3A%2F%2Fschemas.google.com%2Fg%2F2005%23kind%27+term%3D%27http%3A%2F%2Fschemas.google.com%2Fcontact%2F2008%23contact%27%2F%3E%0A%3Cgd%3Aname%3E%0A%3Cgd%3AgivenName%3EPhilippe+Henri+Raymond%3C%2Fgd%3AgivenName%3E%0A%3Cgd%3AfamilyName%3EMichel+%3C%2Fgd%3AfamilyName%3E%0A%3Cgd%3AfullName%3EPhilippe+Henri+Raymond+Michel+%3C%2Fgd%3AfullName%3E%0A%3C%2Fgd%3Aname%3E%0A%3Catom%3Acontent+type%3D%27text%27%3ENotes%3C%2Fatom%3Acontent%3E%0A%3Cgd%3Aemail+rel%3D%27http%3A%2F%2Fschemas.google.com%2Fg%2F2005%23work%27+primary%3D%27true%27+address%3D%27fifoooo%40gmail.com%27+displayName%3D%27Philippe+Henri+Raymond+Michel+%27%2F%3E%0A+++++++++++++++++++++++++++++++++++++%C3%A9%0A%3Cgd%3AphoneNumber+rel%3D%27http%3A%2F%2Fschemas.google.com%2Fg%2F2005%23work%27+primary%3D%27true%27%3E%0A04442453369%0A%3C%2Fgd%3AphoneNumber%3E%0A%3Cgd%3AphoneNumber+rel%3D%27http%3A%2F%2Fschemas.google.com%2Fg%2F2005%23work%27+primary%3D%27true%27%3E%0A%2B33662473369%0A%3C%2Fgd%3AphoneNumber%3E%0A%3Cgd%3AstructuredPostalAddress+rel%3D%27http%3A%2F%2Fschemas.google.com%2Fg%2F2005%23work%27+primary%3D%27true%27%3E%0A%3Cgd%3Acity%3ESausset+les+pins%3C%2Fgd%3Acity%3E%0A%3Cgd%3Astreet%3E9+Avenue+G%C3%A9n%C3%A9ral+de+Gaulle+%3C%2Fgd%3Astreet%3E%0A%3Cgd%3Apostcode%3E13960%3C%2Fgd%3Apostcode%3E%0A%3Cgd%3AformattedAddress%3E%0A9+Avenue+G%C3%A9n%C3%A9ral+de+Gaulle++13960+Sausset+les+pins%0A%3C%2Fgd%3AformattedAddress%3E%0A%3C%2Fgd%3AstructuredPostalAddress%3E%0A%3C%2Fatom%3Aentry%3E&header=Content-type%3A+application%2Fatom%2Bxml%3B+GData-Version%3A+3.0"
As you see there’s certainly a problem about how the gem formats my xml ….
Then comes the response i find in the debugger
Content-Type application/x-www-form-urlencoded is not a valid input type.
So i suppose i have a problem with the formatting of my xml, or maybe my content type is wrong
Ok here is the correct way to call it :