Skip to main content

Notifications

Power Automate - Using Connectors
Unanswered

Extracting Data from an API Response

(0) ShareShare
ReportReport
Posted on by
Hiya,
 
I have an API response from a timesheet system. I want to extract the Timesheet ID and corresponding Period End Date that it relates to and save this down as a variable to use in the next step of the automation.
 
I am new to Power Automate and have been trying to do this using ChatGPT which is just annoying me after providing a large number of inconsistent suggestions.
 
Can anyone suggest a solution please?
 
Many thanks
 
Categories:
  • Mark Nanneman Profile Picture
    Mark Nanneman 831 on at
    Extracting Data from an API Response
    The best way to get started is to set up a simple flow that makes your API call to your timesheet system and look at the data it receives.  Does it return one object or an array of objects?
     
    You can do this by running the flow, and then opening the flow run and slecting the action that makes the API call, and click to view the output.
     
    For example, here I'll inspect the outputs of a sharepoint action.
     
    Click on a test run in the flow log:
    Click on the API action, here I'm selecting the "Get items" action.
     
     
    Most of the time, the output is something like the following.  a value property that has an array of JSON objects with the column names and value pairs.
    {
      "body": {
        "value": [
          {
            "id": 1,
            "title": "record1"
          },
          {
            "id": 2,
            "title": "record2"
          }
        ]
      }
    }
    Here's a real example of a SharePoint Get Items action output:
     
    How you work with the data depends on its structure and what you want to do.  You can Select the properties you want with a Select action to make a smaller array, or to rename the column names, or to combine values from multiple columns into a new one.  Or you can use a loop to loop through the array and do what you need to do with each based on conditional logic. 

    For example I could do an "Apply to Each" loop on "body/value" and reference each "ID" in the loop by typing "item()?['id']" in an expression.
    To store it in a variable, you'd just have to add an action to do that in the loop.
     
    Hope that helps, let us know if you have more specific questions.
     
     

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

End of Year Newsletter…

End of Year Community Newsletter…

Tuesday Tip #12 Start your Super User…

Welcome to a brand new series, Tuesday Tips…

Tuesday Tip #11 New Opportunities…

Welcome to a brand new series, Tuesday Tips…

Leaderboard

#1
WarrenBelz Profile Picture

WarrenBelz 144,609

#2
RandyHayes Profile Picture

RandyHayes 76,287

#3
Pstork1 Profile Picture

Pstork1 64,420

Leaderboard

Featured topics