I am using HTTParty in Ruby to make a Post call. The server expects to see data in the format:
{
"param1": 100,
"params": [
{
"key1": "value1",
"key2": "value2"
},
{
"key1": "value1",
"key2": "value2"
}
]
}
My hash in ruby looks like this
{
"param1"=> 100,
"params"=> [
{
"key1"=> "value1",
"key2"=> "value2"
},
{
"key1"=> "value1",
"key2"=> "value2"
}
]
}
I am making this call
class Http
include HTTParty
end
Http.post(url, {:body => my_hash})
However, the array of hashes is coming incorrectly as
{
"param1": 100,
"params": [
"value1",
"value2",
"value1",
"value2"
]
}
Could someone please help me out on this?
HTTParty, but I did find this example. As it appears virtually identical to what you have (the new form of expressing the hash elements is used, but a hash is a hash), I thought this part might be relevant: "Note that "skip_before_filter :verify_authenticity_token" must be set in the "pears" controller for this example". If I'm way off base let me know and I'll delete this comment.