Topics

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:

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
 

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:

RestClient.post "https://api.sendhub.com/v1/messages/?username=NUMBER\&api_key=API", { 'contacts' => [1111], 'text' => 'Testing }.to_json, :content_typ
 e => 'application/json'
I hope this works.

On Sep 30, 2014, at 2:24 PM, Timothy Fong <timfong888@...> wrote:

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
 


Timothy Fong <timfong888@...>
 

I get the following error (I made some adjustments because of formatting):

RestClient::BadRequest: 400 Bad Request


September 30, 2014 at 2:33 PM
RestClient.post "https://api.sendhub.com/v1/messages/?username=NUMBER\&api_key=API", { 'contacts' => [1111], 'text' => 'Testing }.to_json, :content_typ
e => 'application/json'
I hope this works.



September 30, 2014 at 2:24 PM
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
 

September 30, 2014 at 2:24 PM
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
 


Timothy Fong <timfong888@...>
 

Pretty close, here is what finally worked:

 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'}


September 30, 2014 at 3:57 PM
I get the following error (I made some adjustments because of formatting):

RestClient::BadRequest: 400 Bad Request



September 30, 2014 at 2:33 PM
RestClient.post "https://api.sendhub.com/v1/messages/?username=NUMBER\&api_key=API", { 'contacts' => [1111], 'text' => 'Testing }.to_json, :content_typ
e => 'application/json'
I hope this works.



September 30, 2014 at 2:24 PM
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
 

September 30, 2014 at 2:24 PM
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