****编辑:感谢这些链接,@Hackerman。我能够在Postman中使用Docusign邮递员样本,然后在Powershell中使用它。但是我无法使用我自己的PDF文档。我怀疑这是因为我没有正确地将我的PDF转换为Base64。任何人都知道如何可以通过PowerShell的****完成”PDF文件的验证失败。“当试图通过电子邮件发送签名请求 - docusign
EDIT2:?是能够通过PowerShell来编码我的PDF文件为Base64这个简单的1班轮 $ docEncodedBase64 = [转换] :: ToBase64String((获取 - 内容$ PDFPath -Encoding字节))
我们试图使用Powershell 5.0(和invoke-restmethod
cmdlet)向docusign REST API发出请求,以便通过电子邮件发送签名请求。
在我的测试中,我一直在关注这个指南:https://docs.docusign.com/esign/guide/usage/request_a_signature.html#prepare-the-document-to-send-through-docusign但我得到一个错误,当我把我的POST请求
我们要一个正常的请求(即,不是多部分请求)的路径,从而以base64编码格式的字节形式提供PDF文档作为documentBase64属性的值。
这里是我的代码的PDF转换为Base64字节:
# PDF document
$docContent = Get-Content 'Mutual_NDA.pdf'
# PDF as bytes
$docBytes = [System.Text.Encoding]::Unicode.GetBytes($docContent)
# PDF as Base-64 Encoded bytes
$docEncoded = [System.Convert]::ToBase64String($docBytes)
然后我定义我的JSON有效载荷,这将作为POST请求的正文中发送。在这里,我将'documentBase64'属性设置为上面刚刚转换的base64编码的字符串。
# JSON payload
$jsonPayload = @"
{
"documents": [
{
**"documentBase64": "$docEncoded"**,
"documentId": "1",
"fileExtension": "pdf",
"name": "Mutual_NDA.pdf"
}
],
"emailSubject": "Please sign the NDA",
"recipients": {
"signers": [
{
"email": "[email protected]",
"name": "Darlene Petersen",
"recipientId": "1",
"routingOrder": "1",
"tabs": {
"dateSignedTabs": [
{
"anchorString": "signer1date",
"anchorYOffset": "-6",
"fontSize": "Size12",
"name": "Date Signed",
"recipientId": "1",
"tabLabel": "date_signed"
}
],
"fullNameTabs": [
{
"anchorString": "signer1name",
"anchorYOffset": "-6",
"fontSize": "Size12",
"name": "Full Name",
"recipientId": "1",
"tabLabel": "Full Name"
}
],
"signHereTabs": [
{
"anchorString": "signer1sig",
"anchorUnits": "mms",
"anchorXOffset": "0",
"anchorYOffset": "0",
"name": "Please sign here",
"optional": "false",
"recipientId": "1",
"scaleValue": 1,
"tabLabel": "signer1sig"
}
]
}
}
]
},
"status": "sent"
}
"@
最后,HTTP请求:
$Envelope = Invoke-RestMethod -uri ($BaseURL + '/envelopes') -Method Post -Body $jsonPayload -ContentType 'application/json' -Headers @{"X-Docusign-Authentication" = $XMLHeader}
任何人有这方面的经验?也许我错误地将PDF编码为base64?我真的被卡住了。任何帮助感谢! 谢谢,
埃里克
只是为了测试目的...你可以建立:) – Hackerman
使用像'Postman',一旦你有一个工作负载,端口逻辑另一个工具PowerShell中的有效载荷什么错误??? – 4c74356b41
“错误码”:“PDF_VALIDATION_FAILED”, “消息”:“PDF文件的验证失败。” – Quanda