Question

The following CURL command does what I am trying to achieve with HTTParty.

curl -X POST https://api.spark.io/v1/devices/API_ID /return_num -d access_token=ACCESS_TOKEN -d params=12

I have a basic C function the other end that answers by adding the 12 to a given amount and returns the summed number.

I am calling a post request using httparty like this:

return_hash = HTTParty.post("API_URI/v1/devices/#{API_ID}/return_num", 
  :headers => {"Authorization:" => AUTH}, 
  :query => { :num => self.number})

But this is not sending the self.number through as to the function.

Any ideas?

Was it helpful?

Solution

your doing a POST it should not have a query, it should have a body:

see the example here: http://johnnunemaker.com/httparty/

options = { :body => {:status => text}, :basic_auth => @auth }
post('/statuses/update.json', options)
Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top