I have a use case to call an API to record the entitlements that have been removed on a particular source. The Provisioning Completed trigger returns the following structure:
In the HTTP Request action, I would like to pass the full set of attribute requests to document what has changed on the account. In my request body, I have set a value of {{$.trigger.accountRequests[0].attributeRequests}} which returns an empty string.
In contrast {{$.trigger.accountRequests[0].accountId}} returns “harold.smith”, indicating that the variable substitution is working for strings but not arrays (or JSON objects). The Define Variable action has a similar limitation so I cannot use it to pre-define the array variable to pass in my API request body. Loop wouldn’t work for me either, as I would have to send an API response for each attributeRequest rather than including them all in one.
Has anyone encountered this use case before, and if so, were there any workarounds?
Thank you
I appreciate the suggestion, and while that does seem to work in a JSONPath evaluator it still renders as an empty string in the Workflow engine on the HTTP request body. Here are the relevant lines of the Workflow Result for reference:
Print out of the HTTP step config in the workflow result:
Hi @vijayasaikoppineni , thank you for the suggestion. This does bring me one step closer as it properly fetches the array. Unfortunately, the resultant array seems to get interpreted as part of the request body JSON
In this example, the first quotation mark before attributeName terminates the JSON value and thus the HTTP Request sees it as:`“additional_comments”: “[map[” with a trailing “a” after the value has already closed.
@chris-hogan
In your HTTP Request action, you can build the JSON request body by iterating over the attributeRequests array using Velocity’s #foreach directive.
Thank you for the suggestion. I am not certain whether VTL can be used in the request body as the documentation doesn’t reference it. I have tried the following simple VTL statements to test whether it will execute:
All result in the VTL expression rendering as plain text in the API call. Do you happen to have an example of working VTL usage in the HTTP Request Body?
This is a great suggestion. This did work to properly escape the array in the JSON request body. Unfortunately, our request body still needs other mandatory key value pairs unrelated to the array, so Choose Variable will not suffice.
I am beginning to think it is simply not feasible in workflows, but I appreciate all the help I have received.