2016-12-14 67 views
0

我試圖從v3 SurveyMonkey API發送消息。在此過程中,我使用從API需要以下模式:surveymonkey V3上的錯誤請求錯誤發送

POST /surveys/{id}/collectors 
POST /collectors/{id}/messages 
POST /collectors/{id}/messages/{id}/recipients/bulk 
POST /collectors/{id}/messages/{id}/send 

步驟1-3做工精細,但當我嘗試發出send命令,我得到一個400錯誤請求錯誤。錯誤消息指出:

"The body provided was not a proper JSON string." 

我在R中使用httr包來發送消息,如果有幫助。

u <- paste('https://api.surveymonkey.net/v3/collectors', collectorID, "messages", messageID, "send", sep="/") 
    h <- httr::add_headers(Authorization = token) 

    out <- httr::POST(u, config = h) 

在我查看API文檔時,並沒有看到這個命令需要body。我錯過了什麼?

回答

1

對於步驟4:

POST /collectors/{id}/messages/{id}/send 

的主體實際上是必需的。有一個可選字段(scheduled_date)。如果您希望它在不安排時立即發送,則發送一個空的JSON對象。

'{}' 

而且,這將工作,但它仍然期望一個JSON正文。