handling http post request with httparty

This article gives basic knowledge about handling HTTP post request using httparty gem when response is json. And also if net/http is not working then try using httparty code is below: If you want to learn more about httparty gem click here

Add this code in ruby file. File extension is .rb
  require 'httparty'
  uri = URI("https://www.example.com")
  jsonReponse = {
      "fields": [
          {"name": 'firstname',"value": 'demo'},
          {"name": 'lastname',"value": 'demo'}
      ],
      'extra_fields': {'cookie': cookie_value}
  }
  HTTParty.post(uri, body: jsonReponse.to_json, :headers => {'Content-Type' => 'application/json'})