I have a text input field that takes the string the user writes and stores it in an array variable.
Text Input (inpTags):
I need to append these tags to to a variable that constructs a JSON body to send to Power Automate, to pass inside the body of an API call:
OnSelect button property that sends varJSONBody to Power Automate:
//Separates each tag into it's own record
Set (
varTagsArray,
Split(
inpTags.Text,
","
)
);
//Adds the tags property to the JSON body to send to Power Automate
Set(
varJSONBody,
{
metadata: Patch(
{},
{
tags: varTagsArray.Value
}
),
action: {type: "update"}
}
);
//Run flow
If(
!IsError(
PATCHMetadatafor1Asset.Run(
"assetID",
JSON(
varJSONBody,
JSONFormat.IndentFour
)
)
),
Notify(
"Success! The changes have been applied.",
NotificationType.Success,
5000
)
);
However, the API requires that the tags property is written like a string array, like this:
{metadata:
{tags: ["test", "admin", "team"]}
}
I have been trying to find a way for Power Apps to spit that output but no luck. This is the output:
{
"action": {
"type": "update"
},
"metadata": {
"tags": [
{
"Value": "test"
},
{
"Value": "admin"
},
{
"Value": "team"
}
]
}
}
How can I get this exact output?
{metadata:
{tags: ["test", "admin", "team"]}
}
I've also tried:
{
tags: JSON(varTagsArray.Value, JSONFormat.FlattenValueTables)
}
But I get this:
"tags": "[\"test\",\"admin\",\"team\"]"
Which is closer, but the API call fails if there is a " before the [ and after the ].