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 Automate / Flows is adding double...
Power Automate
Answered

Flows is adding double quotes around an array

(0) ShareShare
ReportReport
Posted on by 166

Not sure why this isn't working as I use it another Flow and it works just fine.

The API I'm working with, when I PUT goes to a URL like this: /custom_field_value/{id}.

Based on the ID, it dictates the data type that it will take. If it is string, the BODY needs to be structured as the following:

PUT string.PNG

If it is in array, it needs to be structured like so:

PUT array.PNG

My array ones are not working, and are receiving double quotes, while others are working perfectly fine. Here are the relevant parts of the Flow since it is quite lengthy and can't be posted here since the image would be too big.

1. Declare the empty array these values will go into:

delcare empty array.PNG

2. If the ID is one that is a multi-choice field (an array), first split the string (Dynamics CRM stores them as a string with commas separating the values, but the API wants an array of strings or integers), then iterate through that created array and append to the empty multiChoicefield array. In this case, I'm converting them to integers, but it takes either (tested via Postman).

construct array.PNG

3. Then send the parameters to the API. (The if() is just checking whether it should send a string or an array).

update custom field.PNG

This is what happens when it fails. Flows doesn't make it easy to see what exactly was sent in the BODY of a request, which is pretty annoying.

4. Failure despite everything looking correct. Fails because "Value is invalid because one or more choice is not on this custom field" which is not true.

failure.PNG

So see exactly what is going on, I have to go into the custom connector and see what is happening.

5. Copy and paste what is being shown for the "id" and "value" into the Test portion of the custom connector:

custom_connector_paste.PNG

6. Of course it fails, so check out the Raw Body and... yep, it is adding double quotes around the array. Yes, the connector has this key as type of string, but it is like that as well in other Flows where this works perfectly.

raw_body.PNG

7. So what should it look like if I fix the Raw Body here:

fixed_raw_body.PNG

8. And it makes it look like this:

fixed_input.PNG

Submitting this works just... but if you just type in exactly what you see here, you get the following in the Raw Body:

wrong.PNG

This is incorrect and ignores the second value as you can see here:

confirmed.PNG

So I am stumped. Especially since I do this in other Flows and works just fine. Even though the custom connector key is of data type string, I can pass in arrays without issue in other Flows I have... just this one is causing a very iritating issue.

Categories:
I have the same question (0)
  • RezaDorrani Profile Picture
    12,143 on at

    Hi @ishraqiyun77 

     

    So if the problem is around the [] in the final output being passed

     

    replace/substring the [ (first character) and ] (last character), which should give you the desired string

     

    I hope I understood your issue correctly

     

    Regards,

    Reza Dorrani

     

    If this post helps, then please consider Accept it as the solution to help the other members find it more quickly

  • ishraqiyun77 Profile Picture
    166 on at

    Hi @RezaDorrani ,

    No, unfrotunately the issue is quotes are being added to the request body, so substr won't work. Is there a way I can just send raw JSON to an end point?

  • RezaDorrani Profile Picture
    12,143 on at

    Hi @ishraqiyun77 

     

    there is a json() expression in Flow

    Try sending your data parsed with json

  • ishraqiyun77 Profile Picture
    166 on at

    @RezaDorrani 

    Yep, no dice.

    I guess the issue is that Value is of type string. Using json(), I also tried array(), it just applies to the value. It seems like I need to construct that whole key:value pair with Compose.

    I'm not sure how in the connector to just negate that so I can build it myself. If I remove it, when I use this action, it will just ask for the ID and I won't be able to pass in value.

    Was hoping there is a way I can either construct it myself, or if there is an action to send to a specific URI without a connector... but then I need to pass my API key in the auth header.

    ID is part of the API URI.

    Capture.PNG

  • RezaDorrani Profile Picture
    12,143 on at

    Hi @ishraqiyun77 

     

    Try generating the Value porperty in a compose action

    and then do json typecast on top of that and see if it works

  • Verified answer
    ishraqiyun77 Profile Picture
    166 on at

    Ok, think I have it sorted it now.

    In the custom connector for this action (PUT), I changed the body from (provided by the company's API docs):

    {
     "custom_field_value": {
     "value": "string"
     }
    }

    To just:

    {
    }

    Which then allowed me to Compose effectively and build the JSON body.

  • RezaDorrani Profile Picture
    12,143 on at

    Great !!!

     

    Glad it finally worked out

     

    Regards,

    Reza Dorrani

     

    If this post helps, then please consider Accept it as the solution to help the other members find it more quickly

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 Automate

#1
Michael E. Gernaey Profile Picture

Michael E. Gernaey 501 Super User 2025 Season 2

#2
Tomac Profile Picture

Tomac 323 Moderator

#3
abm abm Profile Picture

abm abm 237 Most Valuable Professional

Last 30 days Overall leaderboard