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

Announcements

News and Announcements icon
Community site session details

Community site session details

Session Id :
Power Platform Community / Forums / Power Automate / Convert WebServiceResp...
Power Automate
Answered

Convert WebServiceResponse or json string into list or data row

(1) ShareShare
ReportReport
Posted on by 39

Is there any way to convert WebServiceResponse or json string into list or data row.

I want to insert it to SQL table later, so want to create a insert query using the data received as a WebServiceResponse

 

eg.  data is as below

{

"SITEID": "15",

"SITENAME": "ABC"

}

  • mmonline Profile Picture
    169 on at

    Just convert it to a custom object. You can reference the key/value directly or put them into variables and use the variables in the SQL.

     

    mmonline_0-1687948576798.png

    The SQL below assumes both fields are text/string. If the SiteIDField is numeric just remove the single quotes around the value.

    Insert into TABLENAME (SiteIDField, SiteNameField) VALUES ('%SiteId%','%SiteName%')

     

    If you are receiving several site key/value pairs, use a For Each loop to iterate through and build your SQL in the loop.

  • sakshinatekar Profile Picture
    39 on at

    sorry for the confusion. 

    My data is like below

    {
          "db_status": "Success",
          "data": [
                     {
                     "SITEID": "11",
                     "SITENAME": "ABC",
                     }
                     ]
    }

     

    so it gives error to jsonAsObject.SITEID

    Also tried jsonAsObject['data'].SITEID

     

    one more problem found is after making it as a custom object it is converting data as below

    { 'SITEID': 4, 'SITENAME': ABC}

    It is replacing double quotes to single quotes to keys and no quotes to values. This again creates a new problem

  • mmonline Profile Picture
    169 on at

    Before I provide a solution, are the potentially multiple sites returned - where the array of sites several site key/value pairs?

     

    As in:

    {
     "db_status": "Success",
     "data": [
     {
     "SITEID": "11",
     "SITENAME": "ABC",
     },
     {
     "SITEID": "15",
     "SITENAME": "XYZ",
     },
     {
     "SITEID": "18",
     "SITENAME": "QRS",
     }
     ]
    }

     

  • Verified answer
    mmonline Profile Picture
    169 on at

    If your data only has a single site, per JSON returned, you would use:

    theJSONObject.data[0].SITEID & theJSONObject.data[0].SITENAME to reference the keys and return the values.

     

    When you have an array [], the arrays create an ordinal value, starting at 0. So, if there is a single key/value pair, you can always get to it using the [0] indicator.

     

    However, if you have multiple sites returned, per my example above, your flow will look like this.

    mmonline_0-1687958815915.png

     

    You will loop through theJSONObject.data.

     

    Each iteration will return an individual site/sitename pair. I set my For Each variable as currentSite rather than CurrentItem for the sake of variable clarity.

     

    Then, in each iteration I can refer to:

    currentSite.SITEID & currentSite.SITENAME.

     

    Hope that helps.

  • sakshinatekar Profile Picture
    39 on at

    This worked for me. Thanks a lot

  • Suggested answer
    CU03121756-0 Profile Picture
    2 on at
    If you dont Want use Loop then use this Approach

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

Season of Sharing Community Challenge Winners!

Congratulations to our community stars!

Kudos to our 2025 Community Spotlight Honorees

Expanding mentorship, skilling, and AI innovation

Leaderboard > Power Automate

#1
11manish Profile Picture

11manish 321 Super User 2026 Season 2

#2
Mohsin Ali Profile Picture

Mohsin Ali 244

#3
Henil Profile Picture

Henil 102

Last 30 days Overall leaderboard