Hello Guys,
I am getting error in REST API while generating token for specific session.
Here is my code in ruby
require 'uri'
require ‘net/http’
url = URI(“MY_URL/api/tokens”)
http = Net::HTTP.new(url.host, url.port)
http.use_ssl = true
http.verify_mode = OpenSSL::SSL::VERIFY_NONE
request = Net::HTTP::Post.new(url)
request[“content-type”] = ‘multipart/form-data; boundary=----WebKitFormBoundary7MA4YWxkTrZu0gW’
request[“authorization”] = ‘Basic T1BFTlZJRFVBUFA6a25vd2luZzEyMw==’
request[“cache-control”] = ‘no-cache’
request[“postman-token”] = ‘d305cbc3-26a5-eca8-e196-981e132a106b’
request.body = “------WebKitFormBoundary7MA4YWxkTrZu0gW\r\nContent-Disposition: form-data; name=“params[‘session’]”\r\n\r\nses_YV9EN5gXdL\r\n------WebKitFormBoundary7MA4YWxkTrZu0gW–”
response = http.request(request)
puts response.read_body
The error is
JSON parse error: Unexpected character (’-’ (code 45)) in numeric value: expected digit (0-9) to follow minus sign, for valid numeric value; nested exception is com.fasterxml.jackson.core.JsonParseException: Unexpected character (’-’ (code 45)) in numeric value: expected digit (0-9) to follow minus sign, for valid numeric value\n at [Source: (PushbackInputStream); line: 1, column: 3]",
I know error is due to body params. Please let me know how to pass body params in it.