Dropbox Forms API v3 contains several API calls for authentication and workflows. Here are examples of those API requests in Node.js. These examples use the axios request library.
For more information on these endpoints, please refer to the API Documentation.
Get Auth Token:
const getToken = (publicKey, privateKey) => {
const authString = 'Bearer '.concat(privateKey);
const config = {
headers: {'Authorization': authString}
};
const request = axios.get(
`https://api.helloworks.com/v3/token/${publicKey}`,
config)
.then((result) => {
console.log('result', result);
})
.catch(err => {
// handle error
});
}
Shared configuration for all of the workflow instance endpoints:
const baseUrl = 'https://api.helloworks.com/v3';
const token = process.env.HW_TOKEN;
const authString = 'Bearer '.concat(token);
const config = {
headers: {'Authorization': authString}
};
Create Workflow Instance:
const createWorkFlowInstance = () => {
const bodyParameters = {
workflow_id: process.env.WORKFLOW_ID,
participants: {
signer_1: {
type: "email",
value: process.env.MY_EMAIL,
full_name: "James",
}
}
};
const request = axios.post(
`${baseUrl}/workflow_instances`,
bodyParameters,
config)
.then((response) => {
console.log('response', response);
})
.catch(err => {
// handle error
});
};
Get Workflow Instance:
const getWorkflowInstance = (workflowInstanceId) => {
const request = axios.get(
`${baseUrl}/workflow_instances/${workflowInstanceId}`,
config)
.then(response => {
console.log('response', response.data.data);
})
.catch(err => {
// handle error
});
};
Get Workflow Instance Audit Trail:
const getWorkflowInstanceAudit = (workflowInstanceId) => {
const request = axios.get(
`${baseUrl}/workflow_instances/${workflowInstanceId}/audit_trail`,
config
)
.then(response => {
// handle file
})
.catch(err => {
// handle error
});
};
Cancel Workflow Instance:
const cancelWorkflowInstance = (workflowInstanceId) => {
const bodyParameters = {
workflow_instance_id: workflowInstanceId,
};
const request = axios.put(
`${baseUrl}/workflow_instances/${workflowInstanceId}/cancel`,
bodyParameters,
config
)
.then(response => {
console.log('response', response);
})
.catch(err => {
// handle error
});
};
Get Workflow Instance Steps:
const getWorkflowInstanceSteps = (workflowInstanceId) => {
const request = axios.get(
`${baseUrl}/workflow_instances/${workflowInstanceId}/steps`,
config
)
.then(response => {
console.log('response', response);
})
.catch(err => {
// handle error
});
}
Comments
0 comments
Article is closed for comments.