AnsweredAssumed Answered

Request mapping with variables in REST call task

Question asked by savo on Jun 27, 2018
Latest reply on Jul 4, 2018 by savo

The API PUT call I am trying to make definitely works when I am using /api-explorer.html/ or Postman, but when using built-in task it gives me error when executing with status 400.

In Request mapping I have selected JSON Template and put ${myVar} in it. That produces the error. In an user task before I am displaying ${myVar} and if I copy-paste that value manually into JSON Template (when I modify the process), the process finishes fine. So there's something wrong with the format of variable JSON template expects. Key Value mapping is the same.


Here is my code for getting the myVar:


var temp = JSON.parse(execution.getVariable("oldVar"));
var temp1 = temp.formDefinition.fields[0].fields["1"][0].options;
var newOption = {"id": "option_" + temp1.length, "name": execution.getVariable("newProject")};
temp.formDefinition.fields[0].fields["1"][0].options = temp1;
var temp2 = {};
temp2["formRepresentation"] = temp;
execution.setVariable("testVar", JSON.stringify(temp));
execution.setVariable("myVar", JSON.stringify(temp2));

oldVar from the GET call used previously. Script is used to add an entry to a drop-down list.
What is wrong with myVar?