Rest ExecutePost
Use this command to post to a resource using a restful HTTP POST method. You may also want to use this command in conjunction with the REST GETRESPONSESTATUS command to retrieve additional information regarding the status of the request.
Syntax:
REST EXECUTEPOST url USING Source TO Target [Timeout]
where:
- url is the resource where the data will be posted.
- Source is the data to post. Source can be a variable or a document name.
- Target is the variable or document that will contain the response.
- Timeout is the time to wait, in seconds, for the total request.
Syntax example:
CREATE VARIABLE TestPost AS String
CREATE VARIABLE TestPostResponse AS String
SET VARIABLE TestPost = "$MyRequest$"
CREATE DOCUMENT "TestPost.json"
WRITE "TestPost.json" VARIABLE TestPost APPEND
REST SETREQUESTHEADER "Content-Type" "application/json"
REST EXECUTEPOST "https://httpbin.org/post" USING "TestPost.json" TO TestPostResponse
EXPORTVARIABLE TestPostResponse "TestPostResponse.json"
Using password attributes in REST EXECUTEPOST command
You can use password attributes to securely pass sensitive values in REST EXECUTEPOST commands. Reference a password attribute using this syntax:
[[Password,<system password attribute name>]]
For example, you could use this function in the REST body when connecting to an external REST API:
client_secret=[[Password,ASTestPassword]]
Password attributes are resolved server-side at execution time in two scenarios:
- Run using an event
- In batch mode when connected with a service account user
In both cases, the actual secret value is sent to the external endpoint without passing through the client, and password values are never exposed in client-facing output or logs.