agilio | 2020-04-23 19:41:31 UTC | #1
Hi,
I have a data action that pulls back details about a conversation that I am using in an architect flow. Within the contract I'm looking for attributes that may or may not be on the conversation. When those attributes are not there the data action is either not setting variables or is setting them to NULL. Either way the flow bombs out in this condition. I tried modifying the translation map defaults but that isn't forcing a value . I believe it's because the path doesn't exist in the JSON when the attributes are not set. I've included the data action. Any suggestions?Get-Conversation-by-ID-20200423143732.custom.json|attachment (2.2 KB)
crespino | 2020-04-23 20:33:44 UTC | #2
Translation maps use JSONPath expressions to resolve values in the JSON. If you specify an expression to a path that doesn't exist, then the code is probably getting a PathNotFound exceptions which is causing your architect script to fail.
Looking at some JSONPath docs (https://support.smartbear.com/alertsite/docs/monitors/api/endpoint/jsonpath.html) I feel like you can use the [?(expression)] to get around any PathNotFound exceptions by checking for existence in the query. For instance, the following query would only select books that have an 'isbn' property:
$..book[?(@.isbn)]
So maybe you can use that to your advantage to only select nodes in your JSON when the property(ies) that you want exist in the JSON.
anon28066628 | 2020-04-24 15:34:56 UTC | #3
In the action you posted, the translationMap is empty:
"translationMap": { }
The translationMapDefaults won't populate anything that's not defined in the translationMap.
system | 2020-05-25 15:34:59 UTC | #4
This topic was automatically closed 31 days after the last reply. New replies are no longer allowed.
This post was migrated from the old Developer Forum.
ref: 7617