I am trying to use RestClient to do the following which is currently in Curl:
curl -H "Content-Type: application/json" -X POST --data '{"contacts" : [1111],"text" : "Testing"}' https://api.sendhub.com/v1/messages/?username=NUMBER\&api_key=APIKEY
I don't see in the docs for RestClient how to perform the equivalent as "--data" above as well as passing -H (Header) information.
I tried the following:
url = "https://api.sendhub.com/v1/messages/?username=#{NUMBER}\&api_key=#{APIKEY}"
smspacket = "{'contacts':[#{contact_id}], 'text' : ' #{text} ' }"
RestClient.post url , smspacket, :content_type => 'application/json'
But this give me a Bad Request error.
{:accept => '*/*; q=0.5, application/xml', :accept_encoding => 'gzip, deflate'}
. Do you need to use this library? There are many other libraries out there you can use to make http requests.