Docusign request returns error only when tabs set?

2019-09-10 10:19发布

I'm transforming PDF Fields on the associated Document. That works fine -- but I'd like to populate the tabs with values. When I modify the request adding tabs:

  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');

I receive the error:

The request body is missing or improperly formatted. Null object cannot be converted to a value type.

Thanks for your help :) !

I captured the request before being sent to see if it was malformed, but looks ok:

{  
   "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
}

Removing the line signer.setTabs(tabs) allows the request to be processed.

1条回答
戒情不戒烟
2楼-- · 2019-09-10 10:47

I was correctly constructing the request -- but the node client populates all empty model parameters with null

Recursively stripping the nulls from the envelope before submitting the request solved this issue for me:

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;
}
查看更多
登录 后发表回答