Reputation: 67
Im trying to add an extra attribute to the respons object in logic app. I got 2 shape that sending request to two different http. In the third shape i want to merge the body from one respons with the other respons. Like below
"ResponsBody":{
"title": "",
"created": "",
"priority": "",
"Category": "",
"summary": ""
}
So want i want take the ID from one of respons and merge it with the other one.
{
"ID":""
"title": "",
"created": "",
"priority": "",
"Category": "",
"summary": ""
}
So far this is what i get.
23123{"title": "","created": "","priority": "","Category": "","summary":""}
the ID is outside.
Code in Logic app: "body": "@{triggerBody()?['ID']}@{body('Get_HTTP_Info')?['data']}"
Upvotes: 3
Views: 6777
Reputation: 11
In case anyone else ends up here. Better solution exists now.
Microsoft documentation for list of functions for both JSON and XML - HERE
addProperty - Add a property and its value, or name-value pair, to a JSON object, and return the updated object.
coalesce - Return the first non-null value from one or more parameters.
removeProperty - Remove a property from a JSON object and return the updated object.
setProperty - Set the value for a JSON object's property and return the updated object.
xpath - Check XML for nodes or values that match an XPath (XML Path Language) expression, and return the matching nodes or values.
Upvotes: 1
Reputation: 1466
You can use the @union function to merge two objects
"body": "@union(triggerBody(), body('Get_HTTP_Info'))"
To add specific properties only, you can first use a compose action to prepare the content
"compose1": {
"type": "compose"
"inputs": { "id": "@triggerBody()['Id']"}
}
And then you can do
"body": "@union(outputs('compose1'), body('Get_HTTP_Info'))"
Upvotes: 8