2015-10-14 102 views
0

您將很樂意瞭解那些.setRequestHeader設置應該針對此錯誤。DocuSign VBA錯誤400錯誤代碼:ENVELOPE_IS_INCOMPLETE

Public Sub SignatureReq() 
Dim httpRequest As MSXML2.XMLHTTP60 

' defined request and result variables 
Set httpRequest = New XMLHTTP60 

' define the new URL for the signature request using the Base URL returned aboved appended with '/envelopes' 
Dim sigURL As String 
sigURL = URLBase & "/envelopes" 
' currently sig URL is 'https://demo.docusign.net/restapi/v2/accounts/[account number]' 

Dim Body As String 
     Body = "<envelopeDefinition xmlns=\" & Chr(34) & "http://www.docusign.com/restapi\" & Chr(34) & ">" + _ 
      "<accountId>MyAccountID</accountId>" + _ 
      "<status>sent</status>" + _ 
      "<emailSubject>DocuSign API Call - Signature request from template</emailSubject>" + _ 
      "<templateId>MyTemplateID</templateId>" + _ 
      "<templateRoles>" + _ 
      "<templateRole>" + _ 
      "<name>Ronco</name>" + _ 
      "<email>[email protected]</email>" + _ 
      "<roleName>Rono</roleName>" + _ 
      "</templateRole>" + _ 
      "</templateRoles>" + _ 
      "</envelopeDefinition>" 


Debug.Print Body 

httpRequest.Open "POST", sigURL, False 

httpRequest.setRequestHeader Body, "application/xml" 
httpRequest.setRequestHeader "X-DocuSign-Authentication", Author 
'httpRequest.setRequestHeader "Accept", "application/xml" 
httpRequest.setRequestHeader "Content-Type", "multipart/form-data" 
'httpRequest.setRequestHeader "Content-Type", "application/xml" 
httpRequest.send 

Debug.Print httpRequest.Status, "A" 
Debug.Print httpRequest.statusText, "B" 
Debug.Print httpRequest.responseText, "C" 

Exit Sub 

響應信息如下。我明白錯誤來自.setRequestHeader未正確設置。我在哪裏可以找到DocuSign將接受的每個.setRequestHeader需要如何設置標題和值?

400錯誤的請求{「錯誤碼」: 「ENVELOPE_IS_INCOMPLETE」,「消息」:「信封是不完整的 完整的包膜需要的文檔,收件人,標籤和 主題行的內容類型。不包含邊界參數。「 }需要

+0

因此,要回答您的代碼問題,請將application/xml用於您的標題,而不是多部分。 Multipart僅在您使用JSON/XML + FILES時使用。 REST中的每個調用都支持JSON/XML。一些調用支持其他格式,如multipart。這並不能完全回答你的問題,所以我把它留作評論。 – Andrew

回答

0

當發送從模板的Content-Type的簽名請求的API調用被設置爲application/jsonapplication/xml。看起來你現在已經註釋掉了,正在發送multipart/form-data請求。註釋該行並添加回去:

httpRequest.setRequestHeader "Content-Type", "application/xml" 

如果不工作,或者你已經嘗試過,我建議通過您的開發者帳戶偏好啓用請求記錄和檢查多數民衆贊成被設置爲原始請求確保你的代碼正在生成你所期望的。