cancel
Showing results for 
Search instead for 
Did you mean: 
Reply
thomasjames92
Frequent Visitor

Parse JSON Help

Hi,

 

I have an API that I call and return values of a user, unfortunately when I use Parse JSON using powerautomate it doesn't return the correct value (null value). 

 

Everytime I call the API for a user it returns the below, I need to return the ID.

 

{
"results": {
"users": {
"100000": {
"id": 100000,
"first_name": "James",
"last_name": "Smith",
"group_id": 0,
"active": true,
"employee_number": 1,
"salaried": false,
"exempt": false,
"username": "jathomas",
"email": "",
"email_verified": false,
"payroll_id": "000001",
"hire_date": "0000-00-00",
"term_date": "0000-00-00",
"last_modified": "2020-04-28T23:53:45+00:00",
"last_active": "",
"created": "2020-04-28T00:19:08+00:00",
"client_url": "xxxx",
"company_name": "xxx",
"profile_image_url": "",
"display_name": "",
"pronouns": "",
"mobile_number": ""
}
}
}

 

When I use powerautomate, it works correctly for the first user, but the second user returns a null value.

 

empty.PNG

 

Can anyone help me constructing some correct JSON?

 

The current JSON is:

 

{
  "type""object",
  "properties": {
    "results": {
      "type""object",
      "properties": {
        "users": {
          "type""object",
          "properties": {
            "108475": {
              "type""object",
              "properties": {
                "id": {
                  "type""integer"
                },
                "first_name": {
                  "type""string"
                },
                "last_name": {
                  "type""string"
                },
                "group_id": {
                  "type""integer"
                },
                "active": {
                  "type""boolean"
                },
                "employee_number": {
                  "type""integer"
                },
                "salaried": {
                  "type""boolean"
                },
                "exempt": {
                  "type""boolean"
                },
                "username": {
                  "type""string"
                },
                "email": {
                  "type""string"
                },
                "email_verified": {
                  "type""boolean"
                },
                "payroll_id": {
                  "type""string"
                },
                "hire_date": {
                  "type""string"
                },
                "term_date": {
                  "type""string"
                },
                "last_modified": {
                  "type""string"
                },
                "last_active": {
                  "type""string"
                },
                "created": {
                  "type""string"
                },
                "client_url": {
                  "type""string"
                },
                "company_name": {
                  "type""string"
                },
                "profile_image_url": {
                  "type""string"
                },
                "display_name": {
                  "type""string"
                },
                "pronouns": {
                  "type""string"
                },
                "mobile_number": {
                  "type""string"
                }
              }
            }
          }
        }
      }
    }
  }
}
1 ACCEPTED SOLUTION

Accepted Solutions

Hi @thomasjames92 ,

 

I think it is not supported to define a dynamics JSON Schema.

Maybe you need further assistance from Microsoft Support.

Support Request link: https://admin.powerplatform.microsoft.com/support 

 

Sik

View solution in original post

3 REPLIES 3
v-siky-msft
Community Support
Community Support

Hi @thomasjames92 ,

 

The JSON schema can be generated from sample.

Click 'Generate from sample' button, paste the value return from API, the result shows as follows:

{
    "type": "object",
    "properties": {
        "results": {
            "type": "object",
            "properties": {
                "users": {
                    "type": "object",
                    "properties": {
                        "100000": {
                            "type": "object",
                            "properties": {
                                "id": {
                                    "type": "integer"
                                },
                                "first_name": {
                                    "type": "string"
                                },
                                "last_name": {
                                    "type": "string"
                                },
                                "group_id": {
                                    "type": "integer"
                                },
                                "active": {
                                    "type": "boolean"
                                },
                                "employee_number": {
                                    "type": "integer"
                                },
                                "salaried": {
                                    "type": "boolean"
                                },
                                "exempt": {
                                    "type": "boolean"
                                },
                                "username": {
                                    "type": "string"
                                },
                                "email": {
                                    "type": "string"
                                },
                                "email_verified": {
                                    "type": "boolean"
                                },
                                "payroll_id": {
                                    "type": "string"
                                },
                                "hire_date": {
                                    "type": "string"
                                },
                                "term_date": {
                                    "type": "string"
                                },
                                "last_modified": {
                                    "type": "string"
                                },
                                "last_active": {
                                    "type": "string"
                                },
                                "created": {
                                    "type": "string"
                                },
                                "client_url": {
                                    "type": "string"
                                },
                                "company_name": {
                                    "type": "string"
                                },
                                "profile_image_url": {
                                    "type": "string"
                                },
                                "display_name": {
                                    "type": "string"
                                },
                                "pronouns": {
                                    "type": "string"
                                },
                                "mobile_number": {
                                    "type": "string"
                                }
                            }
                        }
                    }
                }
            }
        }
    }
}

Sik

 

The issue is the JSON needs to by dynamic, the above JSON will work for the user 10000 but not 100001.

 

e.g.

body('Parse_JSON')?['10000']?['id']

This will only work for the user 10000

 

I have the user id stored in a variable, is there anyway to create the JSON dynamically e.g.

body('Parse_JSON')?['variables(userID)']?['id']

 

The above does not seem to work though.

 

Hi @thomasjames92 ,

 

I think it is not supported to define a dynamics JSON Schema.

Maybe you need further assistance from Microsoft Support.

Support Request link: https://admin.powerplatform.microsoft.com/support 

 

Sik

View solution in original post

Helpful resources

Announcements
UG GA Amplification 768x460.png

Launching new user group features

Learn how to create your own user groups today!

Power Apps Community Call Jan. 2022 768x460.png

Power Apps Community Call

Please join us on Wednesday, January 19th, at 8a PDT. Come and learn from our amazing speakers!

Community Connections 768x460.jpg

Community & How To Videos

Check out the new Power Platform Community Connections gallery!

Top Solution Authors
Top Kudoed Authors
Users online (1,894)