DocuSign VBA错误400 errorCode:ENVELOPE_IS_INCOMPLETE

时间:2015-10-14 21:32:40

标签: docusignapi

您将非常感谢您了解当前.setRequestHeader设置应该针对此错误。

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>rolsen@myemail.com</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没有正确设置。在哪里可以找到为.setRequestHeader将接受的每个DocuSign设置标头和值的方式?

  

400 Bad Request {“errorCode”:   “ENVELOPE_IS_INCOMPLETE”,“message”:“信封不完整。   完整信封需要文档,收件人,选项卡和a   主题行。 Content-Type不包含边界参数。“}

1 个答案:

答案 0 :(得分:0)

从模板发送签名请求时,API调用的Content-Type需要设置为application/jsonapplication/xml。看起来你现在已经注释掉并发送了multipart/form-data个请求。排除并添加回来的注释:

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

如果这不起作用,或者您已经尝试过,我建议您通过开发者帐户首选项启用请求记录,并检查正在设置的原始请求确保您的代码生成您期望的内容。