我正在转换相关文档上的PDF字段。这工作正常 - 但我想用值填充选项卡。当我修改请求时添加标签:
var text = new docusign.Text();
text.setName('BorrowerName');
text.setValue('Grace Hooper');
text.setLocked('true')
var tabs = new docusign.Tabs();
tabs.setTextTabs([text]);
var signer = new docusign.Signer();
signer.setEmail(signerEmail);
signer.setName(signerName);
signer.setRecipientId('1');
signer.setRoleName('borrower');
signer.setDefaultRecipient('true');
signer.setTabs(tabs);
var recipients = new docusign.Recipients();
recipients.setSigners([signer]);
var inlineTemplate = new docusign.InlineTemplate();
inlineTemplate.setRecipients(recipients);
inlineTemplate.setSequence('1');
var doc = new docusign.Document();
doc.setDocumentBase64(new Buffer(fileBytes).toString('base64'));
doc.setName('youragreeementmiss.pdf');
doc.setDocumentId('1');
doc.setTransformPdfFields('true');
var compositeTemplate = new docusign.CompositeTemplate();
compositeTemplate.setDocument(doc);
compositeTemplate.setInlineTemplates([inlineTemplate]);
compositeTemplate.setServerTemplates([]);
var envDef = new docusign.EnvelopeDefinition();
envDef.setEmailSubject('Thou shalt sign me');
envDef.setCompositeTemplates([compositeTemplate]);
envDef.setStatus('sent');
我收到错误:
The request body is missing or improperly formatted. Null object cannot be converted to a value type.
感谢您的帮助:)!
我在被发送之前捕获了请求,看它是否格式错误,但看起来还不错:
{
"documents":[
{
"documentId":"1",
"uri":null,
"remoteUrl":null,
"name":"youragreeementmiss.pdf",
"password":null,
"transformPdfFields":"true",
"fileExtension":null,
"matchBoxes":[
],
"order":null,
"pages":null,
"documentFields":[
],
"encryptedWithKeyManager":null,
"documentBase64":"",
"applyAnchorTabs":null
}
],
"recipients":{
"signers":[
{
"signatureInfo":null,
"defaultRecipient":"true",
"tabs":{
"signHereTabs":[
],
"initialHereTabs":[
],
"signerAttachmentTabs":[
],
"approveTabs":[
],
"declineTabs":[
],
"fullNameTabs":[
],
"dateSignedTabs":[
],
"envelopeIdTabs":[
],
"companyTabs":[
],
"titleTabs":[
],
"textTabs":[
{
"height":null,
"isPaymentAmount":null,
"formula":null,
"validationPattern":null,
"validationMessage":null,
"shared":null,
"requireInitialOnSharedChange":null,
"senderRequired":null,
"requireAll":null,
"name":null,
"value": "Grace Hopper",
"originalValue":null,
"width":null,
"required":null,
"locked":null,
"concealValueOnDocument":null,
"disableAutoSize":null,
"maxLength":null,
"tabLabel": "BorrowerName",
"font":null,
"bold":null,
"italic":null,
"underline":null,
"fontColor":null,
"fontSize":null,
"documentId":null,
"recipientId":null,
"pageNumber":null,
"xPosition":null,
"yPosition":null,
"anchorString":null,
"anchorXOffset":null,
"anchorYOffset":null,
"anchorUnits":null,
"anchorIgnoreIfNotPresent":null,
"anchorCaseSensitive":null,
"anchorMatchWholeWord":null,
"anchorHorizontalAlignment":null,
"tabId":null,
"templateLocked":null,
"templateRequired":null,
"conditionalParentLabel":null,
"conditionalParentValue":null,
"customTabId":null,
"mergeField":null,
"status":null,
"errorDetails":null
}
],
"numberTabs":[
],
"ssnTabs":[
],
"dateTabs":[
],
"zipTabs":[
],
"emailTabs":[
],
"noteTabs":[
],
"checkboxTabs":[
],
"radioGroupTabs":[
],
"listTabs":[
],
"firstNameTabs":[
],
"lastNameTabs":[
],
"emailAddressTabs":[
],
"formulaTabs":[
]
},
"signInEachLocation":null,
"offlineAttributes":null,
"requireSignerCertificate":null,
"requireSignOnPaper":null,
"canSignOffline":null,
"isBulkRecipient":null,
"bulkRecipientsUri":null,
"recipientSuppliesTabs":null,
"excludedDocuments":[
],
"name":"Grace",
"email":"grace@cobal.com",
"emailRecipientPostSigningURL":null,
"signingGroupId":null,
"signingGroupName":null,
"signingGroupUsers":[
],
"recipientId":"1",
"recipientIdGuid":null,
"accessCode":null,
"addAccessCodeToEmail":null,
"requireIdLookup":null,
"idCheckConfigurationName":null,
"socialAuthentications":[
],
"phoneAuthentication":null,
"samlAuthentication":null,
"smsAuthentication":null,
"userId":null,
"clientUserId":null,
"embeddedRecipientStartURL":null,
"customFields":[
],
"routingOrder":null,
"idCheckInformationInput":null,
"recipientAttachments":[
],
"note":null,
"roleName":null,
"status":null,
"signedDateTime":null,
"deliveredDateTime":null,
"declinedDateTime":null,
"sentDateTime":null,
"declinedReason":null,
"deliveryMethod":null,
"faxNumber":null,
"templateLocked":null,
"templateRequired":null,
"emailNotification":null,
"inheritEmailNotificationConfiguration":null,
"errorDetails":null,
"recipientAuthenticationStatus":null,
"totalTabCount":null
}
],
"agents":[
],
"editors":[
],
"intermediaries":[
],
"carbonCopies":[
],
"certifiedDeliveries":[
],
"inPersonSigners":[
],
"recipientCount":null,
"currentRoutingOrder":null,
"errorDetails":null
},
"customFields":null,
"eventNotification":null,
"allowRecipientRecursion":null,
"templateId":null,
"templateRoles":[
],
"compositeTemplates":[ ],
"accessibility":null,
"transactionId":null,
"status":"sent",
"documentsUri":null,
"recipientsUri":null,
"asynchronous":null,
"envelopeUri":null,
"emailSubject":"Thou shalt sign me",
"emailBlurb":null,
"envelopeId":null,
"signingLocation":null,
"customFieldsUri":null,
"envelopeIdStamping":null,
"authoritativeCopy":null,
"notification":null,
"notificationUri":null,
"enforceSignerVisibility":null,
"enableWetSign":null,
"allowMarkup":null,
"allowReassign":null,
"createdDateTime":null,
"lastModifiedDateTime":null,
"deliveredDateTime":null,
"sentDateTime":null,
"completedDateTime":null,
"voidedDateTime":null,
"voidedReason":null,
"deletedDateTime":null,
"declinedDateTime":null,
"statusChangedDateTime":null,
"documentsCombinedUri":null,
"certificateUri":null,
"templatesUri":null,
"messageLock":null,
"recipientsLock":null,
"brandLock":null,
"brandId":null,
"useDisclosure":null,
"emailSettings":null,
"purgeState":null,
"lockInformation":null,
"is21CFRPart11":null,
"isUniversalSignatureEnvelope":null
}
删除行signer.setTabs(tabs)
可以处理请求。
答案 0 :(得分:5)
我正确构建了请求 - 但是节点客户端使用null
填充所有空模型参数
在提交请求之前以递归方式从信封中删除空值为我解决了这个问题:
removeNulls = function(envelope) {
var isArray = envelope instanceof Array;
for (var k in envelope) {
if (envelope[k] === null) isArray ? obj.splice(k, 1) : delete envelope[k];
else if (typeof envelope[k] == "object") removeNulls(envelope[k]);
if (isArray && envelope.length == k) removeNulls(envelope);
}
return envelope;
}