Hi
I use this code to create a rest api request to my rest api server
var
Pr = Host.createRequest(
"POST"
,
"/track/all"
,
null
).execute();
but i want to set some body parameter to my request how i can do it?
The 3rd parameter of createRequest() method is the request body (null in your example).
Not sure what body your /track/all REST API expects, but here is a sample code showing how to pass a string value when starting a workflow having one input parameter of type string:
var content = {
"parameters": [
{
"type": "string",
"scope": "local",
"name": "param",
"value": {
"string": {
"value": "some sample string value"
}
}
}
]
}
var body = JSON.stringify(content);
var request = host.createRequest("POST", "/workflows/76312d50-3dda-4f09-a6d7-322c652b10a4/executions", body); // vCO REST API to start a workflow given its ID
request.contentType = "application/json";
var response = req.execute();
System.log("response status -> " + response.statusCode);
The 3rd parameter of createRequest() method is the request body (null in your example).
Not sure what body your /track/all REST API expects, but here is a sample code showing how to pass a string value when starting a workflow having one input parameter of type string:
var content = {
"parameters": [
{
"type": "string",
"scope": "local",
"name": "param",
"value": {
"string": {
"value": "some sample string value"
}
}
}
]
}
var body = JSON.stringify(content);
var request = host.createRequest("POST", "/workflows/76312d50-3dda-4f09-a6d7-322c652b10a4/executions", body); // vCO REST API to start a workflow given its ID
request.contentType = "application/json";
var response = req.execute();
System.log("response status -> " + response.statusCode);
Thank you.