cancel
Showing results for 
Search instead for 
Did you mean: 
Reply
Anonymous
Not applicable

How to adapt a parse JSON schema according to answers

Hello,

 

i'm building a flow for my PowerApps application, but i got a problem.

 

I'm using a web-service to get data that I parse with the parse JSON stage. The problem is that the response of my web service is not returning a fix number of objects, it can be 1 as 56.

 

Currently this is my JSON schema : 

{
    "type": "object",
    "properties": {
        "chantiers": {
            "type": "object",
            "properties": {
                "chantier": {
                    "type": "object",
                    "properties": {
                        "code_affaire": {
                            "type": "string"
                        },
                        "code_analytique": {
                            "type": "integer"
                        },
                        "description": {
                            "type": "string"
                        },
                        "distance": {
                            "type": "number"
                        },
                        "ville": {
                            "type": "string"
                        },
                        "bo_fav": {
                            "type": "boolean"
                        }
                    }
                }
            }
        }
    }
}

This schema is working for 1 response but not for more.

 

I got this error message :

errorFlow.PNG

How can i create a "dynamic" schema that is adapting according to the response

Tell me if you need more informations,

 

Thibaut Gautier

7 REPLIES 7
AlanPs1
Resident Rockstar
Resident Rockstar

Hi @Anonymous , thank you for your post in the Flow community.

 

Before suggesting anything else, based on the image you have posted, what I would do is as follows:

Capture-550.png

 

In "Contenu", copy the whole output (ctrl + A / ctrl + C) and rebuild your schema by clicking "Use sample payload".Capture-551.png

 

Once you have done that , try your Flow again. Please let us know how you get on.

 

p.s. Apologies in advance if you have tried this, juist I can't tell if you have or haven't from your post.

 

If you have found my post helpful, please mark thumbs up.

 

Any other questions, just ask.

 

Thanks, Alan

 


Did I answer your question? Mark my post as a solution!

Proud to be a Flownaut!


Anonymous
Not applicable

Hi @AlanPs1 ,

 

firstly thank you for the answer.

 

Actually you're right i did not mention it, i used "Use sample payload" to built my schema.

 

Thanks, Thibaut

Anonymous
Not applicable

I up the topic, maybe for new answers.

AlanPs1
Resident Rockstar
Resident Rockstar

Hi @Anonymous 

Have you rebuilt the schema using the Output from "Contenu"?

 

Just to check you have done that?

 

Thanks, Alan


Did I answer your question? Mark my post as a solution!

Proud to be a Flownaut!


Anonymous
Not applicable

Hello @AlanPs1 ,

 

yes actually i did it several times 

 

Thibaut

AveDog08
Advocate II
Advocate II

I'd like an answer to this as well, I have a weather API in which one of the elements is the date the weather was pulled, so having it in my schema is mucking things up. If I could have the schema update with the date the weather is being pulled from, I would be golden.

AlanPs1
Resident Rockstar
Resident Rockstar

Hi @AveDog08 

Try this schema. This should allow no fixed amount using patternProperties and some RegEx.

It has it's limitations but for your purpose, it may just be what you need.

 

Please paste in and do not build the schema.

{
    "patternProperties": {
        "^.*$": {
            "anyOf": [
                {
                    "type": "string"
                },
                {
                    "type": "null"
                }
            ]
        }
    },
    "additionalProperties": false
}

 

If you find my posts helpful, please mark with thumbs up

 

If this solves your issue, please click "Accept as Solution"

 

Any questions, just ask.

 

Thanks, Alan


Did I answer your question? Mark my post as a solution!

Proud to be a Flownaut!


Helpful resources

Announcements
MPA_User Group Leader_768x460.jpg

Manage your user group events

Check out the News & Announcements to learn more.

V3_PVA CAmpaign Carousel.png

Community Challenge - Giveaways!

Participate in the Power Virtual Agents Community Challenge

Carousel 2021 Release Wave 2 Plan 768x460.jpg

2021 Release Wave 2 Plan

Power Platform release plan for the 2021 release wave 2 describes all new features releasing from October 2021 through March 2022.

PowerPlatform 768x460.png

Microsoft Learn

Check out our new Discover Your Career Path blog post series and get all the details.

Top Solution Authors
Users online (1,477)