@@ -7,14 +7,14 @@ if [[ $SHELL != *"bash"* ]]; then
77 echo " PROBLEM: Run these scripts from within the bash shell."
88fi
99
10- workflow_id =$( cat config/WORKFLOW_ID)
11- if [ -z " $workflow_id " ]; then
10+ workflow_created =$( cat config/WORKFLOW_ID)
11+ if [ -z " $workflow_created " ]; then
1212 bash ./examples/Maestro/utils.sh
1313fi
1414
1515# check that create workflow script ran successfully
16- workflow_id =$( cat config/WORKFLOW_ID)
17- if [ -z " $workflow_id " ]; then
16+ workflow_created =$( cat config/WORKFLOW_ID)
17+ if [ -z " $workflow_created " ]; then
1818 echo " please create a worklow before running this example"
1919 exit 0
2020fi
@@ -28,7 +28,7 @@ ACCESS_TOKEN=$(cat config/ds_access_token.txt)
2828# Note: Substitute these values with your own
2929account_id=$( cat config/API_ACCOUNT_ID)
3030
31- base_path=" https://demo.services. docusign.net/aow-manage/v1.0 "
31+ base_path=" https://api-d. docusign.com/v1 "
3232
3333# Construct your API headers
3434# ds-snippet-start:Maestro1Step2
@@ -43,20 +43,46 @@ echo ""
4343# ds-snippet-start:Maestro1Step3
4444response=$( mktemp /tmp/response-wftmp.XXXXXX)
4545Status=$(
46- curl -w ' %{http_code}' -i -- request GET " ${base_path} /management/ accounts/${account_id} /workflowDefinitions/ ${workflow_id} " \
46+ curl -w ' %{http_code}' -- request GET " ${base_path} /accounts/${account_id} /workflows " \
4747 " ${Headers[@]} " \
4848 --output ${response}
4949)
5050# If the status code returned is greater than 201 (OK / Accepted), display an error message with the API response.
5151if [[ " $Status " -gt " 201" ]]; then
5252 echo " "
53- echo " Unable to retrieve workflow definition with workflow ID: ${workflow_id} "
53+ echo " Unable to retrieve a workflow definition "
5454 echo " "
5555 cat $response
5656 exit 0
5757fi
5858
59- trigger_url=` cat $response | grep triggerUrl | sed ' s/.*\"triggerUrl\":\"//' | sed ' s/\",.*//' `
59+ echo " Response:"
60+ cat $response
61+ echo " "
62+
63+ workflow_id=$( grep -B 1 ' "name": "Example workflow - send invite to signer"' $response | grep ' "id":' | sed -n ' s/.*"id": "\([^"]*\)".*/\1/p' )
64+
65+ # Get the trigger URL
66+ response=$( mktemp /tmp/response-wftmp.XXXXXX)
67+ Status=$( curl -s -w " %{http_code}\n" -i --request GET " ${base_path} /accounts/${account_id} /workflows/${workflow_id} /trigger-requirements" \
68+ " ${Headers[@]} " \
69+ --output ${response} )
70+
71+ # If the status code returned is greater than 201 (OK / Accepted), display an error message with the API response.
72+ if [[ " $Status " -gt " 201" ]]; then
73+ echo " "
74+ echo " Unable to trigger a new instance of the specified workflow ${workflow_id} "
75+ echo " "
76+ cat $response
77+ exit 0
78+ fi
79+
80+ echo " Response:"
81+ cat $response
82+ echo " "
83+
84+ trigger_url=$( grep ' "url":' $response | sed -n ' s/.*"url": "\([^"]*\)".*/\1/p' )
85+ decoded_trigger_url=$( echo $trigger_url | sed ' s/\\u0026/\&/g' )
6086# ds-snippet-end:Maestro1Step3
6187
6288echo " Please input a name for the workflow instance: "
@@ -78,36 +104,26 @@ read cc_email
78104request_data=$( mktemp /tmp/request-wf-001.XXXXXX)
79105printf \
80106' {
81- "instanceName": "' " $instance_name " ' ",
82- "participants": {},
83- "payload": {
107+ "instance_name": "' " $instance_name " ' ",
108+ "trigger_inputs": {
84109 "signerEmail": "' " ${signer_email} " ' ",
85110 "signerName": "' " ${signer_name} " ' ",
86111 "ccEmail": "' " ${cc_email} " ' ",
87112 "ccName": "' " ${cc_name} " ' "
88- },
89- "metadata": {}
113+ }
90114}' > $request_data
91115# ds-snippet-end:Maestro1Step4
92116
93117# ds-snippet-start:Maestro1Step5
94118response=$( mktemp /tmp/response-wftmp.XXXXXX)
95- Status=$( curl -s -w " %{http_code}\n" -- request POST ${trigger_url } \
119+ Status=$( curl -s -w " %{http_code}\n" -i -- request POST ${decoded_trigger_url } \
96120 " ${Headers[@]} " \
97121 --data-binary @${request_data} \
98122 --output ${response} )
99123# ds-snippet-end:Maestro1Step5
100124
101- # If the status code returned is greater than 201 (OK / Accepted), display an error message with the API response.
102- if [[ " $Status " -gt " 201" ]]; then
103- echo " "
104- echo " Unable to trigger a new instance of the specified workflow ${workflow_id} "
105- echo " "
106- cat $response
107- exit 0
108- fi
109125
110- instance_id=` cat $response | grep instanceId | sed ' s/.*\"instanceId \":\"//' | sed ' s/\".*//' `
126+ instance_id=` cat $response | grep instance_id | sed ' s/.*\"instance_id \":\"//' | sed ' s/\".*//' `
111127# Store the instance_id into the config file
112128echo $instance_id > config/INSTANCE_ID
113129
@@ -116,6 +132,12 @@ echo "Response:"
116132cat $response
117133echo " "
118134
135+ instance_url=$( grep ' "instance_url":' $response | sed -n ' s/.*"instance_url": "\([^"]*\)".*/\1/p' )
136+ decoded_instance_url=$( echo $instance_url | sed ' s/\\u0026/\&/g' )
137+ echo " "
138+ echo " Use this URL to complete the workflow steps:"
139+ echo $decoded_instance_url
140+
119141# Remove the temporary files
120142rm " $request_data "
121143rm " $response "
0 commit comments