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
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.

New Process Advisor Capabilities carousel.png

Read the blog for the latest news

Read the latest about new experiences and capabilities in the Power Automate product blog.

PA Survey Carousel Image.png

We want to hear from you!

If you are a small business ISV/Reseller, share your thoughts with our research team.

AI Builder AMA June 7th carousel (up on May 25th, take down June 8th) (1).png

'Ask Microsoft Anything' about AI Builder!

The AI Builder team invite you to ask questions and provide helpful answers at our next AMA.

Users online (1,699)