Input and output parameter mapping for REST Hook
The mapping of input and output parameters for REST Hook and their formats.
- REST Hook input parameters
- REST Hook output parameters
- Example scenarios to call the input and output parameters
- For service instance level parameter details and service instance level parameters in Error flow, see Service instance level parameters.
REST Hook input parameters
The following input parameters are common to all REST Hook activities:
Format:
${resthooks.<id>.<attribute name>}
${resthooks.<id>.url}
${resthooks.<id>.method}
${resthooks.<id>.headers.<name>}
${resthooks.<id>.payload}
${resthooks.<id>.authentication.type}
${resthooks.<id>.authentication.username}
${resthooks.<id>.headers.Content-Type}
${resthoooks.<id>.title}
${resthooks.<ID>.<input>}
REST Hook output parameters
Representing output parameters and attributes of a REST Hook activity within another activity.
-
Response or output or body parameter of REST Hook:
${resthooks.<ID>.output.body}
To get the ID of an activity, see the Source Code tab. The
param_name
is the name of the parameter that is returned by a particular REST Hook activity.For example, the output of REST Hook
resthook_f4c71a
is referenced in email notificationemailnotification_c5ee13
:"resthooks": [ { "resthook": { "title": "resthook_f4c71a", "id": "resthookf342a67e", "headers": { "accept": "application/json", "Content-Type": "application/json" }, "url": "http://9.5.28.173:3000/posts/test_on_error_flow", "method": "GET" } } ], "notifications": [ { "emailnotification": { "title": "emailnotification_c5ee13", "type": "email", "receiverList": "${input_parameters.to}", "id": "emailnot745071d6", "sender": "CAMadmin", "copyToList": "", "subject": "Rest server is accessible", "body": "${resthooks.resthookf342a67e.output.body}" }
-
The following output parameters are common to all REST Hook activities:
Format:
${resthooks.<id>.<attribute name>}
${resthooks.<id>.status} : SUCCESS / FAILED ${resthooks.<id>.body} : response body, JSON object ${resthooks.<id>.status_code} :http status code. For example, 200 OK ${resthooks.<id>.status_message} : http status. For example, 200 OK
Example scenarios to call the input and output parameters
The following example scenarios illustrate the various conventions that you must use to call the input and output parameters:
-
Example 1
{ "ip" : "9.9.9.9", "hostname" : "vm1" }
Syntax:
${resthooks.id.body.ip}
Result is "9.9.9.9
-
Example 2
{ "data" : { "ip" : "9.9.9.9", "hostname" : "vm1" } }
Syntax:
${resthooks.id.body.data.ip}
Result is "9.9.9.9
-
Example 3
{ "zones" : [ { "name" : "east", "percentage" : "25" }, { "name" : "west", "percentage" : "70" } ] }
Syntax:
${resthooks.id.body.zones[name=east].percentage}
or
${resthooks.id.body.zones[0].percentage}
Result: 25
Note: In the following example,
dns_servers
is a variable of list type that is an output from a REST Hook activity:{ "id": "8", "domain": "domain.kstart.com", "hostname": "hostname-cam-local", "ipaddress": "9.9.9.9", "domain_suffix": [ "domain.kstart.com", "domain.kstart.com" ], "dns_servers": [ "9.9.9.0", "9.9.9.1" ] }
The value for the list type is an element of a list and is not a list by itself, so do not enter the following value in the Value field of Edit Parameter > Update tab for a list parameter type:
"vm_1_dns_servers": ["${resthooks.resthookc15774af.output.body.dns_servers}" ],
If you enter the reference JSON value in the Value field, then the following error message is displayed:
Could not parse value for param [vm_1_dns_servers] of type [list] with value : ["["9.9.9.0","9.9.9.1"]"]
Instead, go to the Source tab to reference a value of type list/map.