Posting XML back to server Rails -
as have never done before wondering if either point out resources show best practices when dealing xml (post/puts requests) or perhaps show example.
for example trying post xml google contacts api update contact
what save incoming xml model, edit functionality performed within app , saved model.once updated want post updated contact api in xml format, @ present update email address , persons name
which puts request to
https://www.google.com/m8/feeds/contacts/useremail/full/{contactid}
could offer example of how it?
the xml returned
put /m8/feeds/contacts/default/full/<var>contactid</var> if-match: <var>etag</var> <entry gd:etag='<var>etag</var>'> <id>http://www.google.com/m8/feeds/contacts/<var>useremail</var>/base/<var>contactid</var></id> <updated>2008-02-28t18:47:02.303z</updated> <category scheme='http://schemas.google.com/g/2005#kind' term='http://schemas.google.com/contact/2008#contact'/> <gd:name> <gd:givenname>new</gd:givenname> <gd:familyname>name</gd:familyname> <gd:fullname>new name</gd:fullname> </gd:name> <content type='text'>notes</content> <link rel='http://schemas.google.com/contacts/2008/rel#photo' type='image/*' href='https://www.google.com/m8/feeds/photos/media/<var>useremail</var>/<var>contactid</var>'/> <link rel='self' type='application/atom+xml' href='https://www.google.com/m8/feeds/contacts/<var>useremail</var>/full/<var>contactid</var>'/> <link rel='edit' type='application/atom+xml' href='https://www.google.com/m8/feeds/contacts/<var>useremail</var>/full/<var>contactid</var>'/> <gd:phonenumber rel='http://schemas.google.com/g/2005#other' primary='true'>456-123-2133</gd:phonenumber> <gd:extendedproperty name='pet' value='hamster'/> <gcontact:groupmembershipinfo deleted='false' href='http://www.google.com/m8/feeds/groups/<var>useremail</var>/base/<var>groupid</var>'/> </entry> </pre>
any advice appreciated
thanks
i don't know google contacts api, post/put/get in rails quite simple using net::http, httparty or similar.
in httparty i'm pretty sure it's like:
require 'httparty' response = httparty.put("https://www.google.com/m8/feeds/contacts/useremail/full/{contactid}", :body => { :xml => xml_data })
Comments
Post a Comment