Scenario Blueprint JSON string - Text Parser Replace RegEx

Hello Makers,

I am trying to dynamically modify few specific properties of a Scenario Blueprint JSON string (by calling GET Scenario Blueprint API), to set values against these specific properties, and then finally call a POST Create Scenario.
So, that I can dynamically create a scenario with these modified values, which goes as parameters to Create Scenario API.

I am struggling to come up with a RegEx in TextParser module Replace function to set a new value.

Below is the response of GET Scenario Blueprint API in JSON string format.
And I want set values of (note: scenario don’t know the values in response) the below properties,

*"parameters":{"team":*
*:"channel","channel":*
"EventID":"

Any assistance is greatly appreciated !

{\"flow\":[{\"id\":11,\"mapper\":{},\"module\":\"microsoft-teams:watchMessages1\",\"version\":1,\"metadata\":{\"restore\":{\"parameters\":{\"team\":{\"mode\":\"edit\"},\"choose\":{\"label\":\"Watch Channel Messages\"},\"__IMTCONN__\":{\"data\":{\"scoped\":\"true\",\"connection\":\"azure\"},\"label\":\"xxxxx\"}}},\"designer\":{\"x\":0,\"y\":0},\"parameters\":[{\"name\":\"__IMTCONN__\",\"type\":\"account:azure\",\"label\":\"Connection\",\"required\":true},{\"name\":\"choose\",\"type\":\"select\",\"label\":\"Choose a Type of Messages to be Watched\",\"required\":true,\"validate\":{\"enum\":[\"channel\",\"chat\"]}},{\"name\":\"limit\",\"type\":\"uinteger\",\"label\":\"Limit\",\"required\":true},{\"name\":\"team\",\"type\":\"select\",\"label\":\"Team ID\",\"required\":true},{\"name\":\"channel\",\"type\":\"any\",\"label\":\"Channel ID\",\"required\":true}]},\"parameters\":{\"team\":\"00000000-000-0000-0000-0000000000\",\"limit\":2,\"choose\":\"channel\",\"channel\":\"00:0000aa2722544ef1b848d4f00000000@thread.tacv2\",\"__IMTCONN__\":3122}},{\"id\":9,\"mapper\":{\"Email\":\"\",\"Phone\":\"\",\"Status\":\"not started\",\"DueDate\":\"{{addMinutes(now; 30)}}\",\"EventID\":\"00000000-000-0000-0000-0000000000\",\"FARefNo\":\"\",\"IssueID\":\"\",\"Category\":\"NewUser\",\"FileName\":\"\",\"LastName\":\"\",\"Priority\":\"High\",\"FirstName\":\"\",\"IssueRefNo\":\"\",\"UserRoleID\":\"\",\"Description\":\"{{11.body.content}}\",\"CMEventBoardID\":\"\",\"ResponseTeamID\":\"\",\"ClientContactID\":\"00000000-000-0000-0000-0000000000\",\"IsNotifyAssignee\":false},\"module\":\"json:CreateJSON\",\"version\":1,\"metadata\":{\"expect\":[{\"name\":\"ClientContactID\",\"type\":\"text\",\"label\":null,\"required\":true},{\"name\":\"EventID\",\"type\":\"text\",\"label\":null,\"required\":true},{\"name\":\"Priority\",\"type\":\"text\",\"label\":null,\"required\":true},{\"name\":\"Description\",\"type\":\"text\",\"label\":null,\"required\":true},{\"name\":\"Status\",\"type\":\"text\",\"label\":null,\"required\":true},{\"name\":\"DueDate\",\"type\":\"text\",\"label\":null,\"required\":true},{\"name\":\"FileName\",\"type\":\"text\",\"label\":null},{\"name\":\"IsNotifyAssignee\",\"type\":\"boolean\",\"label\":null,\"required\":true},{\"name\":\"IssueID\",\"type\":\"text\",\"label\":null},{\"name\":\"CMEventBoardID\",\"type\":\"text\",\"label\":null},{\"name\":\"FARefNo\",\"type\":\"text\",\"label\":null},{\"name\":\"IssueRefNo\",\"type\":\"text\",\"label\":null},{\"name\":\"FirstName\",\"type\":\"text\",\"label\":null},{\"name\":\"LastName\",\"type\":\"text\",\"label\":null},{\"name\":\"ResponseTeamID\",\"type\":\"text\",\"label\":null},{\"name\":\"UserRoleID\",\"type\":\"text\",\"label\":null},{\"name\":\"Category\",\"type\":\"text\",\"label\":null},{\"name\":\"Email\",\"type\":\"text\",\"label\":null},{\"name\":\"Phone\",\"type\":\"text\",\"label\":null}],\"restore\":{\"expect\":{\"IsNotifyAssignee\":{\"mode\":\"chose\"}},\"parameters\":{\"type\":{\"label\":\"Create Event Task\",\"nested\":[{\"name\":\"ClientContactID\",\"type\":\"text\",\"label\":null,\"default\":null,\"required\":true,\"multiline\":false},{\"name\":\"EventID\",\"type\":\"text\",\"label\":null,\"default\":null,\"required\":true,\"multiline\":false},{\"name\":\"Priority\",\"type\":\"text\",\"label\":null,\"default\":null,\"required\":true,\"multiline\":false},{\"name\":\"Description\",\"type\":\"text\",\"label\":null,\"default\":null,\"required\":true,\"multiline\":false},{\"name\":\"Status\",\"type\":\"text\",\"label\":null,\"default\":null,\"required\":true,\"multiline\":false},{\"name\":\"DueDate\",\"type\":\"text\",\"label\":null,\"default\":null,\"required\":true,\"multiline\":false},{\"name\":\"FileName\",\"type\":\"text\",\"label\":null,\"default\":null,\"required\":false,\"multiline\":false},{\"name\":\"IsNotifyAssignee\",\"type\":\"boolean\",\"label\":null,\"default\":false,\"required\":true},{\"name\":\"IssueID\",\"type\":\"text\",\"label\":null,\"default\":null,\"required\":false,\"multiline\":false},{\"name\":\"CMEventBoardID\",\"type\":\"text\",\"label\":null,\"default\":null,\"required\":false,\"multiline\":false},{\"name\":\"FARefNo\",\"type\":\"text\",\"label\":null,\"default\":null,\"required\":false,\"multiline\":false},{\"name\":\"IssueRefNo\",\"type\":\"text\",\"label\":null,\"default\":null,\"required\":false,\"multiline\":false},{\"name\":\"FirstName\",\"type\":\"text\",\"label\":null,\"default\":null,\"required\":false,\"multiline\":false},{\"name\":\"LastName\",\"type\":\"text\",\"label\":null,\"default\":null,\"required\":false,\"multiline\":false},{\"name\":\"ResponseTeamID\",\"type\":\"text\",\"label\":null,\"default\":null,\"required\":false,\"multiline\":false},{\"name\":\"UserRoleID\",\"type\":\"text\",\"label\":null,\"default\":null,\"required\":false,\"multiline\":false},{\"name\":\"Category\",\"type\":\"text\",\"label\":null,\"default\":\"NewUser\",\"required\":false,\"multiline\":false},{\"name\":\"Email\",\"type\":\"text\",\"label\":null,\"default\":null,\"required\":false,\"multiline\":false},{\"name\":\"Phone\",\"type\":\"text\",\"label\":null,\"default\":null,\"required\":false,\"multiline\":false}]},\"space\":{\"label\":\"Empty\"}}},\"designer\":{\"x\":300,\"y\":0},\"parameters\":[{\"name\":\"type\",\"type\":\"udt\",\"label\":\"Data structure\",\"required\":true},{\"name\":\"space\",\"type\":\"select\",\"label\":\"Indentation\",\"validate\":{\"enum\":[\"tab\",\"2\",\"4\"]}}]},\"parameters\":{\"type\":912,\"space\":\"\"}},{\"id\":10,\"mapper\":{\"ca\":\"\",\"qs\":[],\"url\":\"https://dev-api.cqcommand.com/api/v1/Board/Task/Insert\",\"data\":\"{{9.json}}\",\"gzip\":true,\"method\":\"post\",\"headers\":[],\"timeout\":\"\",\"useMtls\":false,\"authPass\":\"\",\"authUser\":\"\",\"bodyType\":\"raw\",\"contentType\":\"application/json\",\"serializeUrl\":false,\"shareCookies\":false,\"parseResponse\":false,\"followRedirect\":true,\"useQuerystring\":false,\"followAllRedirects\":false,\"rejectUnauthorized\":true},\"module\":\"http:ActionSendData\",\"version\":3,\"metadata\":{\"expect\":[{\"name\":\"url\",\"type\":\"url\",\"label\":\"URL\",\"required\":true},{\"name\":\"serializeUrl\",\"type\":\"boolean\",\"label\":\"Serialize URL\",\"required\":true},{\"name\":\"method\",\"type\":\"select\",\"label\":\"Method\",\"required\":true,\"validate\":{\"enum\":[\"get\",\"head\",\"post\",\"put\",\"patch\",\"delete\",\"options\"]}},{\"name\":\"headers\",\"spec\":[{\"name\":\"name\",\"type\":\"text\",\"label\":\"Name\",\"required\":true},{\"name\":\"value\",\"type\":\"text\",\"label\":\"Value\"}],\"type\":\"array\",\"label\":\"Headers\"},{\"name\":\"qs\",\"spec\":[{\"name\":\"name\",\"type\":\"text\",\"label\":\"Name\",\"required\":true},{\"name\":\"value\",\"type\":\"text\",\"label\":\"Value\"}],\"type\":\"array\",\"label\":\"Query String\"},{\"name\":\"bodyType\",\"type\":\"select\",\"label\":\"Body type\",\"validate\":{\"enum\":[\"raw\",\"x_www_form_urlencoded\",\"multipart_form_data\"]}},{\"name\":\"parseResponse\",\"type\":\"boolean\",\"label\":\"Parse response\",\"required\":true},{\"name\":\"authUser\",\"type\":\"text\",\"label\":\"User name\"},{\"name\":\"authPass\",\"type\":\"password\",\"label\":\"Password\"},{\"name\":\"timeout\",\"type\":\"uinteger\",\"label\":\"Timeout\",\"validate\":{\"max\":300,\"min\":1}},{\"name\":\"shareCookies\",\"type\":\"boolean\",\"label\":\"Share cookies with other HTTP modules\",\"required\":true},{\"name\":\"ca\",\"type\":\"cert\",\"label\":\"Self-signed certificate\"},{\"name\":\"rejectUnauthorized\",\"type\":\"boolean\",\"label\":\"Reject connections that are using unverified (self-signed) certificates\",\"required\":true},{\"name\":\"followRedirect\",\"type\":\"boolean\",\"label\":\"Follow redirect\",\"required\":true},{\"name\":\"useQuerystring\",\"type\":\"boolean\",\"label\":\"Disable serialization of multiple same query string keys as arrays\",\"required\":true},{\"name\":\"gzip\",\"type\":\"boolean\",\"label\":\"Request compressed content\",\"required\":true},{\"name\":\"useMtls\",\"type\":\"boolean\",\"label\":\"Use Mutual TLS\",\"required\":true},{\"name\":\"contentType\",\"type\":\"select\",\"label\":\"Content type\",\"validate\":{\"enum\":[\"text/plain\",\"application/json\",\"application/xml\",\"text/xml\",\"text/html\",\"custom\"]}},{\"name\":\"data\",\"type\":\"buffer\",\"label\":\"Request content\"},{\"name\":\"followAllRedirects\",\"type\":\"boolean\",\"label\":\"Follow all redirect\",\"required\":true}],\"restore\":{\"expect\":{\"qs\":{\"mode\":\"chose\"},\"method\":{\"mode\":\"chose\",\"label\":\"POST\"},\"headers\":{\"mode\":\"chose\"},\"bodyType\":{\"label\":\"Raw\"},\"contentType\":{\"label\":\"JSON (application/json)\"}}},\"designer\":{\"x\":600,\"y\":0},\"parameters\":[{\"name\":\"handleErrors\",\"type\":\"boolean\",\"label\":\"Evaluate all states as errors (except for 2xx and 3xx )\",\"required\":true},{\"name\":\"useNewZLibDeCompress\",\"type\":\"hidden\"}]},\"parameters\":{\"handleErrors\":false,\"useNewZLibDeCompress\":true}}],\"name\":\"MSTeams Notifications (Watch)\",\"metadata\":{\"instant\":false,\"version\":1,\"designer\":{\"orphans\":[]},\"scenario\":{\"dlq\":false,\"dataloss\":false,\"maxErrors\":3,\"autoCommit\":true,\"roundtrips\":1,\"sequential\":false,\"confidential\":false,\"autoCommitTriggerLast\":true}}}

Since the response is json why not just use the map() function rather than parsing the json manually? The json structure is a native data structure that can be accessed with the internal Make array functions.

1 Like