Skip to content

Commit ca8f400

Browse files
use SDK method for triggerWorkflow
1 parent 225f4c5 commit ca8f400

File tree

1 file changed

+31
-6
lines changed

1 file changed

+31
-6
lines changed

lib/maestro/examples/triggerWorkflow.js

Lines changed: 31 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -42,12 +42,37 @@ const triggerWorkflow = async (workflow, args) => {
4242
metadata: {}
4343
});
4444

45-
const response = await makePostRequest(workflow.triggerUrl, triggerPayload, {
46-
headers: {
47-
Authorization: `Bearer ${args.accessToken}`,
48-
'Content-Type': 'application/json',
49-
},
50-
});
45+
const triggerUrl = workflow.triggerUrl.toString();
46+
const mtidIndex = triggerUrl.indexOf("mtid");
47+
const mtsecIndex = triggerUrl.indexOf("&mtsec");
48+
const mtid = triggerUrl.substring(mtidIndex+5, mtsecIndex);
49+
const mtsec = triggerUrl.substring(mtsecIndex+7)
50+
const basePath = triggerUrl.substring(0,triggerUrl.indexOf("/accounts"));
51+
52+
console.log(basePath);
53+
54+
const options = {
55+
mtid: mtid,
56+
mtsec: mtsec
57+
}
58+
59+
console.log(options);
60+
61+
const dsApiClient = new docusign.ApiClient();
62+
dsApiClient.setBasePath(basePath);
63+
dsApiClient.addDefaultHeader('Authorization', `Bearer ${args.accessToken}`);
64+
65+
console.log("before call");
66+
67+
const workflowTriggerApi = new docusign.WorkflowTriggerApi(dsApiClient);
68+
const response =
69+
await workflowTriggerApi.triggerWorkflow(
70+
triggerPayload,
71+
args.accountId,
72+
options
73+
);
74+
75+
console.log(response);
5176

5277
return response;
5378
};

0 commit comments

Comments
 (0)