Httparty POST/PUT example

Hi all,

I need to do POST/PUT operation using httparty.

I have a default class as follows

require ‘httparty’

class Webclient
include HTTParty

def intialize(options = {})

parameters to build the url

end
end

with the help of httparty,
i can easily use get operation as follows

Webclient.get(“url”)

Can anyone give me an example of how to do POST/PUT operations through
httparty over a Rest webservice, where i need to post/Put the entire XML

for example,
XML content is like below
<ns:sample xmlns:ns=“somelocation”>

</ns:sample>

I need to post/put the whole xml content using HTTParty as

Webclient.post(url,“XMLContent”)
Webclient.put(url,“XMLContent”)

can any one give me an example of how to post/put the whole xml using
httparty under a class which includes httparty

Thanks in advance

I am not sure if you Googled it .
But first link was this
http://stackoverflow.com/questions/3773939/can-someone-provide-an-example-for-how-to-post-xml-using-httparty-and-ruby-on-ra

I am not sure how it is related to JRuby though.

I tried with that. But its not working … can you please help

You haven’t given us a lot to go on, but in general you use the same
format you’d use for get:

Client.post(url,:query => { :param => “value” },
:headers => { “Authorization” => “THISISMYAPIKEY”})

This forum is not affiliated to the Ruby language, Ruby on Rails framework, nor any Ruby applications discussed here.

| Privacy Policy | Terms of Service | Remote Ruby Jobs