I'm trying to use the Docusign node sdk to create an envelope from a template that already exists in the Docusign developer account.
However I always get a 400 response with this message: {"errorCode":"INVALID_REQUEST_PARAMETER","message":"The request contained at least one invalid parameter. Query parameter 'from_date' must be set to a valid DateTime or 'envelope_ids', 'folder_ids' or 'transaction_ids' must be specified."}
The full error object shows that the request being made is to GET /restapi/v2.1/accounts/{accountId}/envelopes. Which I imagine means it is trying to return the envelope that should have just been created.
I can't see how I can influence this call as it's not called directly.
The process I'm following:
The code in question:
this.dsApiClient.addDefaultHeader(
'authorization',
`Bearer ${response.body.access_token}`,
);
const envelopesAPI = new EnvelopesApi(this.dsApiClient);
const envelopeDefinition: EnvelopeDefinition = {
templateId,
templateRoles: [
{
name: profile.displayName,
email: profile.defaultEmailAddress,
clientUserId: profile.personId,
roleName: 'Demo'
},
],
status: 'sent',
};
const envelope = await envelopesAPI.createEnvelope(
this.configService.get('docusign.auth.accountId'),
{
envelopeDefinition: envelopeDefinition,
},
);
However other APIs via the sdk such as
await templatesApi.listTemplates(this.configService.get('docusign.auth.accountId'))
Return a 200 response and expected data.
You must provide a roleName
for any role in your templateRoles
in order to send an envelope based on a template. So your code should be like this:
this.dsApiClient.addDefaultHeader(
'authorization',
`Bearer ${response.body.access_token}`,
);
const envelopesAPI = new EnvelopesApi(this.dsApiClient);
const envelopeDefinition: EnvelopeDefinition = {
templateId,
templateRoles: [
{
name: profile.displayName,
email: profile.defaultEmailAddress,
clientUserId: profile.personId,
roleName: 'yourRoleName'
},
],
status: 'sent',
};
const envelope = await envelopesAPI.createEnvelope(
this.configService.get('docusign.auth.accountId'),
{
envelopeDefinition: envelopeDefinition,
},
);
See more information here - https://developers.docusign.com/docs/esign-rest-api/how-to/request-signature-template-remote/
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.