azure-logic-appsmicrosoft-dynamicsazure-logic-app-standard

Getting rid of "body" from an array content when appending it to a JSON API request payload in Logic Apps


I'm new to Logic Apps and I think this is a basic data manipulation problem, but I have been stucked on it for few days now and I hope someone can help me.

I have an Azure Logic Apps worklow which is querying a bunch of addresses from Dataverse and it is then:

  1. Parsing the JSON
  2. Creating an array of addresses by getting rid of all the odata metadata and selecting only the fields that I need
  3. Sending an API request to a 3rd party entity by appending the array content to the API request.

This is how the workflow looks like in this screenshot.

querying part

Unfortunately the API request I'm sending is not formatted correctly because it looks like this.

enter image description here

but it is expected as in this screenshot.

enter image description here

So basically I don't know how to append just the array content without the body, which is coming out as output of the "Select" action.

enter image description here

The "Select" action has been set up as in this screenshot.

enter image description here

I thought I had to use that action and not a compose cause some of those AddressLine fields are optional and when using a Compose action in a For Each loop, it causing the workflow failing because of the fields missing.

Anyway, any advice on how to manipulate the data properly and build the JSON API request as expected? Any help is much appreciated!

Thanks!

I tried also replacing the array with a string approach, but it didn't look like a clean practice, cause then I had to manipulate the string to replace some characters when appending it to the JSON payload, and when sending it to the 3rd party, for some reason, it was picking up only the first item of the list of addresses, and not all of them.


Solution

  • In order to get rid of body parameter from Select action's output, I have used Append to string variable action and added body('Select') as value in it.

    enter image description here

    enter image description here

    By doing so, I am able to get the expected output without any string manipulation.

    enter image description here