cancel
Showing results for 
Search instead for 
Did you mean: 
Reply
titlerequired
Regular Visitor

PowerAutomate - JSON Schema

I'm using PowerAutomate to query an API. It successfully returns a JSON which is an array of objects. Im struggling to run an 'apply to each' against the results and i think it is due to the JSON schema i am using to parse the json response body. The apply to each doesnt seem to be able to distinguish the different objects inside the array. Does anyone have any experience of that, and could offer some suggestions?

3 REPLIES 3
sudharsan1985
Solution Sage
Solution Sage

Hi @titlerequired 

Try to use the action Parse JSON with some sample JSON data, which will create a schema based on the sample data. Also, to better understand the issue, please post some screenshots.

Hope it helps, please like it or mark it as a solution if it resolves your clarification or issue
-Sudharsan K...

Thanks for the reply.

 

I have been trying to create a schema based on the response data (which i have done in previous steps) but i dont really understand the structure of how the schema should be.

 

The response body might contain several devices, or many devices, each with 00s of properties but i really only want 5 or 6 of them.

 

1 of the properties may or may not exist.

 

If someone could help me to make a schema to only capture or pass certain properties through that would be really helpful.

 

This was a schema i tried a few attempts back,

 

{
  "type": "object",
  "items": {
    "type": "array",
    "properties": {
      "_id": {
        "type": "string"
      },
      "ip": {
        "type": "string"
      },
      "mac": {
        "type": "string"
      },
      "model": {
        "type": "string"
      },
      "type": {
        "type": "string"
      },
      "version": {
        "type": "string"
      }
    },
    "required": [
      "_id",
      "ip",
      "mac",
      "model",
      "type",
      "version"
    ]
  }
}

 

And the response,

power1.png

Hi @titlerequired 

Your requirement is obscure to me. But the error is due to the direct access of the object, and you shouldn't send the object instead try to add it to an array and send the array, it should work.

 

Hope it helps, please like it or mark it as a solution if it resolves your clarification or issue
-Sudharsan K...

Helpful resources

Announcements
Power Platform Conf 2022 768x460.jpg

Join us for Microsoft Power Platform Conference

The first Microsoft-sponsored Power Platform Conference is coming in September. 100+ speakers, 150+ sessions, and what's new and next for Power Platform.

New Ideas Forum MPA.jpg

A new place to submit your Ideas for Power Automate

Announcing a new way to share your feedback with the Power Automate Team.

MPA Virtual Workshop Carousel 768x460.png

Register for a Free Workshop

Learn to digitize and optimize business processes and connect all your applications to share data in real time.

MPA Licensing.jpg

Ask your licensing questions at the Power Automate AMA!

Join Priya Kodukula and the licensing team, super users and MVPs to find answers to your questions on Power Automate licensing.

Users online (2,297)