The flow stops due to an error in the JSON Parser step
- 新着としてマーク
- ブックマーク
- 購読
- ミュート
- RSS フィードを購読する
- ハイライト
- 印刷
- 不適切なコンテンツを報告
2 時間前
I have configured the following actions in the flow:
① Script step
② REST step
③ JSON Parser step
If step ③ returns an error, the entire flow stops, and subsequent processing does not run.
Therefore, I contacted Now Support and would like to change step ③ to a Script step to prevent the flow from stopping, but I am unable to configure it properly.
Is there a way to do this?
I want the “outputs” to look like the image.
The processing in step ③ is as follows:
■Source
・Source data:②REST step > 応答本文
-----
{
"Responcemessage":"Success",
"Return": {
"detail":"True",
"SubnetName":"subnet-a",
"NSG_Name":"nsg-b",
"Delegation":"-"
}
}
-----
■Target
・Label:root
・Name:root
・Type:Object
・Mandatory:false
The script when step ③ is changed to a Script step is as follows.
・Required Runtime:Instance
・Input Variables
response_body:②REST step > 応答本文
・Script
(function execute(inputs, outputs) {
if (!gs.nil(inputs.response_body)) {
try {
var responseObj = JSON.parse(inputs.response_body);
outputs.Responcemessage = responseObj.Responcemessage || "";
outputs.Returndet = responseObj.detail || "";
outputs.Returnsub = responseObj.subnet_name || "";
outputs.Returnnsg = responseObj.nsg_name || "";
outputs.Returndeleg = responseObj.delegation || "-";
} catch (ex) {
outputs.Responcemessage = "failed";
}
} else {
outputs.Responcemessage = "failed";
}
})(inputs, outputs);
・Output Variables
Responcemessage
Returndet
Returnsub
Returnnsg
Returndeleg
- 新着としてマーク
- ブックマーク
- 購読
- ミュート
- RSS フィードを購読する
- ハイライト
- 印刷
- 不適切なコンテンツを報告
1時間前
Hi @NaoyaT ,
As per my analysis why your script is not working
JSON :
{
"Responcemessage":"Success",
"Return": {
"detail":"True",
"SubnetName":"subnet-a",
"NSG_Name":"nsg-b",
"Delegation":"-"
}
}
therefore correct path will be
responseObj.Return.detail
responseObj.Return.SubnetName
responseObj.Return.NSG_Name
responseObj .Return.Delegation
can you try this of fetching the data
Regards
BK
LinkedIn: https://www.linkedin.com/in/bhavyashree-karanth-55032a121
YouTube: https://www.youtube.com/@NowWithBhavya
