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.

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.

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
Microsoft 365 Conference – December 6-8, 2022

Microsoft 365 Conference – December 6-8, 2022

Join us in Las Vegas to experience community, incredible learning opportunities, and connections that will help grow skills, know-how, and more.

Difinity Conference 2022

Difinity Conference 2022

Register today for two amazing days of learning, featuring intensive learning sessions across multiple tracks, led by engaging and dynamic experts.

European SharePoint Conference

European SharePoint Conference

The European SharePoint Conference returns live and in-person November 28-December 1 with 4 Microsoft Keynotes, 9 Tutorials, and 120 Sessions.

Users online (5,025)