Reputation: 63
I want to integrate the Routific API into a Rails application. I made my request with HTTParty but I get the following message {"error"=>"Expecting JSON data in the body"}
I don't understand... I am sending the json in the body. Please check my code below.
Thanks for your help
Julien
file = File.read("#{Rails.root}/app/controllers/demo.json")
api_key = "eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJfaWQiOiI1ODE3M2ZiNTk1NzRjZTFiMmZhNWEwNTAiLCJpYXQiOjE0Nzc5MTg2NDZ9.extq0nKtPGwj6VXxMpj9u8uapasKVSorWeTBFW7HgOE"
headers = {
"Content-Type:" => "application/json",
'authorization'=> 'bearer ' + api_key
}
@results = HTTParty.post("https://api.routific.com/v1/vrp",
:headers => headers,
:body => file.to_json)
Upvotes: 2
Views: 231
Reputation: 663
you added invalid headers
it should be "Content-Type" instead of "Content-Type:" (without colon)
Upvotes: 2