添加eventNotification后Docusign INVALID_REQUEST_BODY
问题描述:
尝试将webhook status添加到工作良好的Docusign集成API时,它开始给我一个错误INVALID_REQUEST_BODY。添加eventNotification后Docusign INVALID_REQUEST_BODY
由于我使用的是PHP API,我不写了JSON有效载荷自己,PHP的DocuSign包负责序列化的东西,但是,它说INVALID_REQUEST_BODY,指着这里:
"eventNotification":[{"url":"https:\/\/xxx.yyyy.zzz.com\/docusign\/webhook",
^
我也尝试删除一切,只发送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":"[email protected]","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":"[email protected]","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."
}
那么发生了什么?
答
您错误地将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": "[email protected]",
"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"
}
你是绝对正确的,现在工作得很好,谢谢!但是,该信息是否可以在Web界面(https://appdemo.docusign.com/documents)中获得?由于Docusign未触及我的webhook网址,因此我想检查网址和状态是否正确存储在信封中。 –
请参阅此[回答](http://*.com/a/43222592/1219543)解决连接问题。 –