У меня есть следующий код:Ruby Typhoeus gem - Недействительный Json в теле?
require 'Typhoeus'
url = Typhoeus::Request.new("https://fluidsurveys.com/api/v2/webhooks/subscribe/",
userpwd: "username_test:password_test",
method: :post,
body: {
'subscription_url' => 'http://glacial-spire-test.herokuapp.com/hooks/response_created_callback',
'event' => 'response_complete'
},
headers: { 'Content-Type' => "application/json"})
response = url.run.body
puts response
Это возвращает код ответа 400
и ошибка:
Content-Type set to application/json but could not decode valid JSON in request body.
здесь находятся документы для API вызова творю: http://docs.fluidsurveys.com/api/webhooks.html
POST /api/v2/webhooks/subscribe/¶
Returns a status of 409 if a webhook with the subscription url already exists. Returns a
status of 201 if the webhook was successfully created. Requests must be sent as an
application/json-encoded dictionary with the required fields subscription_url and event
Образец запроса (ПО ДОСКАМ):
{
"subscription_url": "http://fluidsurveys.com/api/v2/callback/",
"event": "response_complete",
"survey": 1,
"collector": 1
}
Что я здесь делаю неправильно? опрос и сборщик являются необязательными параметрами, и я не вижу проблемы с json в своем теле.
Это волшебство, которое делает его! Благодарю. – Luigi