web
You’re offline. This is a read only version of the page.
close
Skip to main content

Notifications

Announcements

Community site session details

Community site session details

Session Id :
Power Platform Community / Forums / Power Apps / Create String Array WI...
Power Apps
Answered

Create String Array WITHOUT "Value" Column in Power Apps

(1) ShareShare
ReportReport
Posted on by 12
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 ].
I have the same question (0)
  • Suggested answer
    VASANTH KUMAR BALMADI Profile Picture
    266 on at

    *** RESPONSE from ChatGPT ***

    To properly format the tags property as a string array, you need to ensure that Power Apps is sending the tags as an actual array of strings, not as an array of objects or as a string representation of the array.

    The issue you're facing is that Split(inpTags.Text, ",") creates a table (not an array), and when you try to use varTagsArray.Value, you're getting objects with a Value field, which isn't what the API expects.

    Here’s how you can modify your code to correctly generate the array:

    Solution:

    1. Use the ForAll function to iterate over the varTagsArray and extract the Value of each element.
    2. Construct a proper array of strings in JSON format.

    Updated Code:

    // Separates each tag into its own record
    Set(
    varTagsArray,
    Split(inpTags.Text, ",")
    );
    
    // Adds the tags property to the JSON body to send to Power Automate
    Set(
    varJSONBody,
    {
    metadata: {
    tags: ForAll(
    varTagsArray,
    Text(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
    )
    );

    Explanation:

    • Split(inpTags.Text, ","): Splits the input string into a table of tags.
    • ForAll(varTagsArray, Text(Value)): Iterates over the varTagsArray and extracts the Value from each row, which represents each tag as a string. This is what the API expects, an array of strings.
    • JSON(varJSONBody, JSONFormat.IndentFour): Converts the varJSONBody into a properly formatted JSON string with indentation.

    Expected Output:

    The result of the above logic should be a JSON body in the correct format for the API:

    {
    "metadata": {
    "tags": ["test", "admin", "team"]
    },
    "action": {
    "type": "update"
    }
    }

    This should successfully send the data in the expected format to Power Automate, and the API should accept it without issues.

    Why Previous Attempts Didn't Work:

    • JSON(varTagsArray.Value, JSONFormat.FlattenValueTables): This approach turned the array into a string representation of the array (i.e., "[\"test\",\"admin\",\"team\"]"), which includes extra escape characters and is not recognized by the API as a valid array.
    • Using varTagsArray.Value directly: This was returning the Value field from each element in the array, which is an object, not the expected string format.

    With this solution, you're explicitly creating an array of strings that matches the expected format.

  • CU09121927-0 Profile Picture
    12 on at
    Thank you for your suggestion @VASANTH KUMAR BALMADI.
    Unfortunately, this is the output I am getting with your code:
    {
        "action": {
            "type": "update"
        },
        "metadata": {
            "tags": [
                {
                    "Value": "test"
                },
                {
                    "Value": " admin"
                },
                {
                    "Value": " team"
                }
            ]
        }
    }
     
    Could you show me your implementation with screenshots to see how you are getting that output? 
  • WarrenBelz Profile Picture
    153,075 Most Valuable Professional on at
    Try this - workaround due to difficulty in getting Power Apps to insert double quotes without regarding them as a string separator.
    With(
       {
          _Tags: 
          "{metadata:{tags:['" & Concat(
             Split(
                inpTags.Text,
                ","
             ),
             Value,
             "','"
          ) & "']}}"
       },
       Set(
          varTagsArray,
          Substitute(
             _Tags,
             "'",
             """"
          )
       )
    )
    Please click Does this answer your question if my post helped you solve your issue. This will help others find it more readily. It also closes the item. If the content was useful in other ways, please consider giving it a Like.
    MVP (Business Applications)    Visit my blog Practical Power Apps    LinkedIn    Buy me a coffee
  • CU09121927-0 Profile Picture
    12 on at
    Hi @WarrenBelz, thank you for your response. Your solution does work, until I have to pass the varJSONBody variable as a parameter for the Power Automate flow. The JSON() function makes the output transform back into: 
    "[\"test\",\" admin\",\" team\"]"
    Even if it was well-formatted before that.
     
    How can I fix this part of the code?
    If(
        !IsError(
            PATCHMetadatafor1Asset.Run(
                "assetID",
                JSON(
                    varJSONBody,
                    JSONFormat.IndentFour
                )
            )
        ),
        Notify(
            "Success! The changes have been applied.",
            NotificationType.Success,
            5000
        )
    );
     
    If I try to delete the JSON() function, it returns this error:
     
    Invalid argument type (Record). Expecting a Text value instead.
  • Verified answer
    WarrenBelz Profile Picture
    153,075 Most Valuable Professional on at
    Hi @CU09121927-0​​​​​​​
    Why bother with the JSON - it is already in the format you need.
    With(
       {
          _Tags: 
          Substitute(
             "{metadata: {tags:['" & 
             Concat(
                Split(
                   inpTags.Text,
                   ","
                ),
                Value,
                "','"
             ) & "']},action: {type: 'update'}})",
             "'",
             """"
          )
       },
       If(
          !IsError(
             PATCHMetadatafor1Asset.Run(
                "assetID",
                _Tags
             )
          ),
          Notify(
             "Success! The changes have been applied.",
             NotificationType.Success,
             5000
          )
       )
    )


    Please click Does this answer your question if my post helped you solve your issue. This will help others find it more readily. It also closes the item. If the content was useful in other ways, please consider giving it a Like.
    MVP (Business Applications)    Visit my blog Practical Power Apps    LinkedIn    Buy me a coffee
  • CU09121927-0 Profile Picture
    12 on at
    Thank you @WarrenBelz. I was hesitant to drop the JSON() and Patch() functions since I need the final JSON to be dynamic. Depending on user input, the JSON will have a different number of JSON attributes. But I ended up just writing a bunch of If() statements that add the necessary commas conditionally. Thanks for your help!

Under review

Thank you for your reply! To ensure a great experience for everyone, your content is awaiting approval by our Community Managers. Please check back later.

Helpful resources

Quick Links

Forum hierarchy changes are complete!

In our never-ending quest to improve we are simplifying the forum hierarchy…

Ajay Kumar Gannamaneni – Community Spotlight

We are honored to recognize Ajay Kumar Gannamaneni as our Community Spotlight for December…

Leaderboard > Power Apps

#1
WarrenBelz Profile Picture

WarrenBelz 721 Most Valuable Professional

#2
Michael E. Gernaey Profile Picture

Michael E. Gernaey 320 Super User 2025 Season 2

#3
Power Platform 1919 Profile Picture

Power Platform 1919 268

Last 30 days Overall leaderboard