Forum Discussion

Anonymous's avatar
Anonymous
Not applicable
7 years ago
Solved

Convert a list to array and Pass to JSON body

Hi,

I'm new to Power BI. 

I would like to pass existing list of values as array to the JSON body. 

List

27767321

27739924

27739926

body = "{""taskId"":[27767321,27739924,27739926]}", <-- THIS WORKS

 

However, I want to make it dynamic and pass an array. with opening and closing square brackets in the JSON body "[" "]" 

 

Please help me:

1. Convert a list to an array 

body = "{""taskId"":" & [listname] & "}",

2. Have JSON body with Square brackets to specify array of list

  • Anonymous try following,

     

    on your list , click advanced editor and add following step

     

     MyList = Text.Combine( LastStepofList, ",")
    In
    MyList

    Basically it will combine your list into text, comma seperated and in your json query, in advanced editor do following:

     

    body = "{""taskId"":[" & MyListQuery & "]}",

     

     

1 Reply

  • Anonymous try following,

     

    on your list , click advanced editor and add following step

     

     MyList = Text.Combine( LastStepofList, ",")
    In
    MyList

    Basically it will combine your list into text, comma seperated and in your json query, in advanced editor do following:

     

    body = "{""taskId"":[" & MyListQuery & "]}",