I have made a POST to a site using Httparty with the following code:
HTTParty.post("http://example.com", :body => application_hash.to_json, :headers => {'Content-Type' => 'application/json'})
How can I check what the response code was for this submission?
The return value of the post method is a HTTParty::Response
object, which has a code method. Assign your response to a variable and use that to take a look at the http status code:
response = HTTParty.post("http://example.com", :body => application_hash.to_json, :headers => {'Content-Type' => 'application/json'})
response.code
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With