Date
1 - 5 of 5
convert Curl with headers -H and -- data to RestClient
Timothy Fong <timfong888@...>
How do I convert the following to Restclient?
curl -H "Content-Type: application/json" -X POST --data '{"contacts" : [1111],"text" : "Testing"}' https://api.sendhub.com/v1/messages/?username=NUMBER\&api_key=APIKEY
|
|
Kannan Manickam <kannan@...>
RestClient.post "https://api.sendhub.com/v1/messages/?username=NUMBER\&api_key=API", { 'contacts' => [1111], 'text' => 'Testing }.to_json, :content_type => 'application/json' I hope this works.
On Sep 30, 2014, at 2:24 PM, Timothy Fong <timfong888@...> wrote:
|
|
Tim Fong <timfong888@...>
Hi I tried this but it an auth error. Let me try again. Sent from my iPhone
On Sep 30, 2014, at 2:33 PM, Kannan Manickam <kannan@...> wrote:
|
|
Timothy Fong <timfong888@...>
I get the following error
(I made some adjustments because of formatting):
toggle quoted messageShow quoted text
RestClient::BadRequest: 400 Bad Request
|
|
Timothy Fong <timfong888@...>
Pretty close, here is what
finally worked:
toggle quoted messageShow quoted text
url_sms = "https://api.sendhub.com/v1/messages/?username=#{NUMBER}\&api_key=#{APIKEY}" smspacket = {:contacts => ["#{contact_id}"], :text => "#{botresponse}" }.to_json response = RestClient.post url_sms , smspacket, {:content_type => 'application/json'}
|
|