Node.js调用DocuSign API预填充PDF失败求助
DocuSign预填充PDF失效问题排查求助
我通过DocuSign API Request Builder生成了用于预填充PDF的Node.js脚本,原本期望预填充指定PDF后发送给相关签署人完成签署操作,但脚本执行后仅发送了空白PDF,预填充功能完全未生效。以下是我的脚本代码、EnvelopeDefinition配置及PDF截图,请求帮忙排查问题:
脚本代码
#!/usr/bin/env node // DocuSign API Request Builder example. Generated: Wed, 29 May 2024 09:49:27 GMT // DocuSign Ⓒ 2024. MIT License -- https://opensource.org/licenses/MIT 'use strict'; const fse = require('fs-extra') , path = require('path') , docusign = require('docusign-esign') , baseUri = 'https://demo.docusign.net/' // Note: the accessToken is for testing and is temporary. It is only good for 8 hours from the time you // authenticated with API Request Builder. In production, use an OAuth flow to obtain access tokens. , accessToken = '' , accountId = '' , documentDirectory = '.'; // The directory with your documents // Send the envelope async function sendDocuSignEnvelope () { let templateRole1 = docusign.TemplateRole.constructFromObject({ email: "demo+rent@gmail.com", name: "pejel", roleName: "Lessor" }); let templateRole2 = docusign.TemplateRole.constructFromObject({ email: "komoca2257@bsomek.com", name: "John Doe", roleName: "Owner" }); let templateRoles1 = [templateRole1, templateRole2]; let envelopeDefinition = docusign.EnvelopeDefinition.constructFromObject({ PrefillTabs: [object Object], status: "created", templateId: "1bd33b79-268e-46b2-a947-d8b7580504d6", templateRoles: templateRoles1 }); try { const dsApi = new docusign.ApiClient(); dsApi.addDefaultHeader('Authorization', 'Bearer ' + accessToken); dsApi.setBasePath(baseUri + 'restapi'); const envelopesApi = new docusign.EnvelopesApi(dsApi); const envResults = await envelopesApi.createEnvelope(accountId, {envelopeDefinition: envelopeDefinition}); console.log (`Create envelope results: ${JSON.stringify(envResults, null, ' ')}`); console.log (`The envelopeId is ${envResults.envelopeId}`); return envResults.envelopeId; } catch (e) { console.log (`Error from DocuSign create envelope: ` + `${(e && e.response && JSON.stringify(e.response.body))||e}`); return false } } /** * Create the recipient view URL * NOTE: the URL is time limited and must be used within a couple of minutes */ async function recipientView (envelopeId) { let recipientViewRequest = false; if (!recipientViewRequest || !envelopeId) {return} try { const dsApi = new docusign.ApiClient() dsApi.addDefaultHeader('Authorization', 'Bearer ' + accessToken); dsApi.setBasePath(baseUri + 'restapi'); const envelopesApi = new docusign.EnvelopesApi(dsApi); const viewResults = await envelopesApi.createRecipientView(accountId, envelopeId, {recipientViewRequest: recipientViewRequest}); console.log (`\nCreate recipient view succeeded.`); console.log (`Open the signing ceremony's long URL within 5 minutes: \n${viewResults.url}\n\n`); } catch (e) { console.log (`Error from DocuSign create recipient view: ` + `${(e && e.response && JSON.stringify(e.response.body))||e}`); } } // The mainline /** * The mainline can't use "await". So this intermediate function is used. */ async function asyncMainline() { let envelopeId; envelopeId = await sendDocuSignEnvelope(); await recipientView (envelopeId); console.log("Done.\n"); } asyncMainline()
EnvelopeDefinition配置
{ "templateId": "1bd33b79-268e-46b2-a947-d8b7580504d6", "PrefillTabs": { "radioGroupTabs": [ { "groupName": "property_usage", "radios": [ { "selected": "true", "value": "check_residential" }, { "selected": "false", "value": "check_commercial" }, { "selected": "false", "value": "check_industrial" } ] } ], "textTabs": [ { "tabLabel": "created_date", "value": "29-05-2024" }, { "tabLabel": "owner_name", "value": "John Doe" }, { "tabLabel": "lessor_name", "value": "Property Management Company" }, { "tabLabel": "lessor_email", "value": "tenants.dxb@ifpm.ae" }, { "tabLabel": "lessor_phone", "value": "054 307 0621" }, { "tabLabel": "lessor_emirate_id", "value": "Landlord Emirates ID" }, { "tabLabel": "tenant_name", "value": "pejel" }, { "tabLabel": "tenant_email", "value": "vishalsg42+rent@gmail.com" }, { "tabLabel": "tenant_phone", "value": "08879423195" }, { "tabLabel": "tenant_emirate_id", "value": "111-1111-11111111-1" }, { "tabLabel": "number_of_co_occupants", "value": "1" }, { "tabLabel": "plot_no", "value": "" }, { "tabLabel": "building_name", "value": "" }, { "tabLabel": "property_type", "value": "undefined" }, { "tabLabel": "location", "value": "undefined" }, { "tabLabel": "property_no", "value": "undefined" }, { "tabLabel": "property_area", "value": "undefined" }, { "tabLabel": "start_date", "value": "2024-05-20T06:42:32.532Z" }, { "tabLabel": "end_date", "value": "2024-06-19T06:42:32.532Z" }, { "tabLabel": "rent_amount", "value": "12000" }, { "tabLabel": "contract_value", "value": "12000" }, { "tabLabel": "security_deposit", "value": "500" }, { "tabLabel": "mode_of_payment", "value": "Online & Cheques" } ] }, "templateRoles": [ { "email": "demo+rent@gmail.com", "name": "pejel", "roleName": "Lessor" }, { "email": "komoca2257@bsomek.com", "name": "John Doe", "roleName": "Owner" } ], "status": "created" }
PDF表单截图

内容的提问来源于stack exchange,提问作者vishal gupta
相关产品推荐
相关产品推荐

