0
我有以下代碼:紅寶石百頭巨怪的寶石 - 無效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
樣品請求(根據DOCS):
{
"subscription_url": "http://fluidsurveys.com/api/v2/callback/",
"event": "response_complete",
"survey": 1,
"collector": 1
}
我在這裏做錯了什麼?調查和收集器是可選的參數,可以和我沒有看到一個問題,在我的身體JSON。
它的魔力,那就是了!謝謝。 – Luigi