2017-04-05 138 views
2

嘗試將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." 
} 

那麼發生了什麼?

回答

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": "[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" 
} 
+0

你是絕對正確的,現在工作得很好,謝謝!但是,該信息是否可以在Web界面(https://appdemo.docusign.com/documents)中獲得?由於Docusign未觸及我的webhook網址,因此我想檢查網址和狀態是否正確存儲在信封中。 –

+0

請參閱此[回答](http://stackoverflow.com/a/43222592/1219543)解決連接問題。 –

相關問題