在尝试将webhook status添加到运行良好的Docusign集成API时,它开始给我一个错误INVALID_REQUEST_BODY。
由于我正在使用PHP API,我不是自己编写JSON有效负载,Docusign PHP包负责序列化事物,但是,它说INVALID_REQUEST_BODY,指向这里:
"eventNotification":[{"url":"https:\/\/xxx.yyyy.zzz.com\/docusign\/webhook",
^
我还尝试删除其他所有内容,只发送url参数。试图更改URL,只发送一个域。没有任何效果。如果我发送事件通知我得到错误,如果我不发送它,一切正常。
如果您向其发送错误命名的项目,Docusign PHP包会引发异常,因此,我也确定EventNotification模型非常正确。
这是完整的错误消息,没有敏感数据:
[DEBUG] HTTP Request body ~BEGIN~
{"documents":[{"documentId":1,"name":"XXXXXXXXXX.pdf","documentBase64":"XXXXXXXX="}],"recipients":{"signers":[{"tabs":{"signHereTabs":[{"documentId":1,"recipientId":1,"pageNumber":1,"anchorString":"recipient_signature"}]},"name":"xxxxxxxxx","email":"xx@xxxxxxxx.com","recipientId":1,"clientUserId":XXXX}]},"eventNotification":[{"url":"https:\/\/xxx.yyyy.zzz.com\/docusign\/webhook","loggingEnabled":"true"}],"status":"sent","emailSubject":"XXXXXX - XXXXXX Certification","brandId":"xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx"}
~END~
* Hostname demo.docusign.net was found in DNS cache
* Trying 162.248.186.25...
* TCP_NODELAY set
* Connected to demo.docusign.net (162.248.186.25) port 443 (#0)
* TLS 1.2 connection using TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384
* Server certificate: demo.docusign.net
* Server certificate: Symantec Class 3 EV SSL CA - G3
* Server certificate: VeriSign Class 3 Public Primary Certification Authority - G5
> POST /restApi/v2/accounts/XXXXXX/envelopes HTTP/1.1
Host: demo.docusign.net
User-Agent: PHP-Swagger/2.0.0
X-DocuSign-Authentication: {"Username":"dev@xxxx.com","Password":"xxxxxxx","IntegratorKey":"XXX-XXXXXXXX-XXX-XXXX-xxxxx-xxxxxxxxxxxx"}
X-DocuSign-SDK: PHP
Accept: application/json
Content-Type: application/json
Content-Length: 3981
Expect: 100-continue
< HTTP/1.1 100 Continue
* We are completely uploaded and fine
< HTTP/1.1 400 Bad Request
< Cache-Control: no-cache
< Content-Length: 725
< Content-Type: application/json; charset=utf-8
< X-DocuSign-TraceToken: c227xxxx
< Date: Wed, 05 Apr 2017 00:13:16 GMT
< Strict-Transport-Security: max-age=31536000; includeSubDomains
<
* Curl_http_done: called premature == 0
* Connection #0 to host demo.docusign.net left intact
[DEBUG] HTTP Response body ~BEGIN~
{
"errorCode": "INVALID_REQUEST_BODY",
"message": "The request body is missing or improperly formatted. Cannot deserialize the current JSON array (e.g. [1,2,3]) into type 'API_REST.Models.v2.eventNotification' because the type requires a JSON object (e.g. {\"name\":\"value\"}) to deserialize correctly.\r\nTo fix this error either change the JSON to a JSON object (e.g. {\"name\":\"value\"}) or change the deserialized type to an array or a type that implements a collection interface (e.g. ICollection, IList) like List<T> that can be deserialized from a JSON array. JsonArrayAttribute can also be added to the type to force it to deserialize from a JSON array.\r\nPath 'eventNotification', line 1, position 3790."
}
那发生了什么事?
答案 0 :(得分:2)
您错误地将eventNotification参数用作数组。
以下内容应该有效。我删除了方括号[]
"eventNotification": {
"url": "https:\/\/xxx.yyyy.zzz.com\/docusign\/webhook",
"loggingEnabled": "true"
}
这是您的完整要求
{
"documents": [ { "documentId": 1, "name": "XXXXXXXXXX.pdf", "documentBase64": "XXXXXXXX=" } ],
"recipients": {
"signers": [
{
"tabs": {
"signHereTabs": [
{
"documentId": 1,
"recipientId": 1,
"pageNumber": 1,
"anchorString": "recipient_signature"
}
]
},
"name": "xxxxxxxxx",
"email": "xx@xxxxxxxx.com",
"recipientId": 1,
"clientUserId": XXXX
}
]
},
"eventNotification": {
"url": "https:\/\/xxx.yyyy.zzz.com\/docusign\/webhook",
"loggingEnabled": "true"
},
"status": "sent",
"emailSubject": "XXXXXX - XXXXXX Certification",
"brandId": "xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx"
}