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 / Data Table to JSON obj...
Power Automate
Unanswered

Data Table to JSON object in PAD

(1) ShareShare
ReportReport
Posted on by 10

Hi!

 

I have a data table (in Excel) that I need to send via an API call (invoke web action) in Power Automate Desktop.

 

Is there an easy way to convert this table to a JSON object? Or how is this usually handled in similar situations when data needs to get passed via this action?

 

Also, I noticed that in Winautomation there were the features of creating a new custom object and adding a new property to a custom object. Has this action been removed in PAD?

 

Thanks in advance for any input.

I have the same question (0)
  • Verified answer
    Community Power Platform Member Profile Picture
    on at

    Power Automate Desktop is able to convert a custom object's property with datatable/datarow in it straight into JSON.

    You can create a custom object with:

     

     

     

    %NewVar% = %{{ }}%

     

     

     

    Then create a new property and assign your datatable (note that if property does not exist, it creates it for you in the object. That is why there is no command 'add property to custom object').

     

     

     

    %NewVar['Table']% = %Table%

     

     

     

    Then you can convert your custom object to JSON with the command 'Convert custom object to JSON'. The result will be a list of objects.

  • LyCo Profile Picture
    10 on at

    Ok, makes sense! Thanks a lot!

  • vamsi_varanasi Profile Picture
    152 on at

    @Anonymous - Thanks for the solution. 

     

    Could you please explain a bit more, I am in need of this solution. I have a two dimensional data table in PAD and have to pass this data table object or JSON to power automate to parse. 

  • Agnius Bartninkas Profile Picture
    Most Valuable Professional on at

    @vamsi_varanasi, it is quite straight forward. When you have a table in a variable (e.g. %Table%), you can simply push it into a custom object and then convert it to Json.

     

    Here's a quick sample. I created a simple Excel file with the following table:

    KeyValue
    One1
    Two2
    Three3

     

    I then read the file, extracting data so that the first row is a header row. Here's the result from PAD:

    AgniusBartninka_0-1635580375713.png

    I then used the following three actions (you can copy and paste this directly to PAD):

     

    SET NewVar TO {{ }}
    SET NewVar['Table'] TO Table
    Variables.ConvertCustomObjectToJson CustomObject: NewVar Json=> CustomObjectAsJson

     

    Looks like this in PAD:

    AgniusBartninka_1-1635580441905.png

     

    What it does is as follows:

    1. Create a new empty custom object named %NewVar% (you don't really need to create a new object if you already have one, though)
    2. Add a property named 'Table' to the custom object with %Table% as its value*
    3. Convert the custom object to Json

    Note: If you already have a property with the same name in the object, it will be overwritten. If you do not, it will be added as a new property.

     

    The custom object (%NewVar%) will look like this:

    AgniusBartninka_2-1635580759102.png

    The 'Table' property inside of it will look like this:

    AgniusBartninka_3-1635580784145.png

    And the Json data after conversion (%CustomObjectAsJson%) will look like this:

     

    {"Table":[{"Key":"One","Value":"1"},{"Key":"Two","Value":"2"},{"Key":"Three","Value":"3"}]}

     

    As you can see, it basically is converted into a list of objects, with each row being a list item, and each value being added with the column names as keys.

    This can then easily be parsed by Power Automate.

  • vamsi_varanasi Profile Picture
    152 on at

    Thank you very much for your explanation @Agnius .

     

    My data table is below ( two dimensional table ) which contained 50 records 

     

    vamsi_varanasi_0-1635589704594.png

     

    I hope the same below syntax should work for above table as well.  Please correct me if I am wrong.

     

    vamsi_varanasi_1-1635589801016.png

     

    Do you have any suggestion how to delete any specific row from  above data table ?

     

    Thanks,

     

  • Agnius Bartninkas Profile Picture
    Most Valuable Professional on at

    It should definitely work, with the exception that you need to use proper variable names. Mine were just examples.

    As for deleting rows from a table - there is no action that would allow doing it. If you want to do that, the only viable option is instead of pushing the entire table into the object, instead create a new separate list, loop through the rows of the table and add the relevant rows to this list, while skipping those that are irrelevant. You can then add the list of rows into the object and convert it to JSON. The end result will be exactly the same, but with less rows (excluding those you skipped in the loop).

  • vamsi_varanasi Profile Picture
    152 on at

    Thanks @Agnius , do we need to create a empty list ( %List[]%) or do we need to create a Empty Data table ( %Table[][]%) to push the specific records ?

  • Agnius Bartninkas Profile Picture
    Most Valuable Professional on at

    That is up to you, but since your goal is converting it to JSON, you are perfectly fine with having an empty list and pushing data table rows as list items into the list. This is because as soon as you convert it from a custom object to JSON, you will anyway end up with having a list of objects. Attempting to create a new table and then push values to each column in each row will simply make your flow more complex without bringing any added benefit.

  • vamsi_varanasi Profile Picture
    152 on at

    Thank you again @Agnius .

     

    vamsi_varanasi_0-1635601885023.png

     

    When I am following the same steps, I am facing the below issue while assigning the list to the custom object ? do you think what could be the issue ?

     

  • Agnius Bartninkas Profile Picture
    Most Valuable Professional on at

    Well, the error is quite self explanatory - the variable does not exist, meaning you have not created the object, before trying to add the property to it.

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 522 Super User 2025 Season 2

#2
Tomac Profile Picture

Tomac 364 Moderator

#3
abm abm Profile Picture

abm abm 243 Most Valuable Professional

Last 30 days Overall leaderboard