cancel
Showing results for 
Search instead for 
Did you mean: 
Reply
Highlighted
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
Highlighted
Community Support
Community Support

Re: Parse JSON Help

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
Highlighted
Community Support
Community Support

Re: Parse JSON Help

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

 

Highlighted
Frequent Visitor

Re: Parse JSON Help

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.

 

Highlighted
Community Support
Community Support

Re: Parse JSON Help

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
secondImage

Demo-Extravaganza 2020

Check out these cool Power Apps & vote on your favorite!

secondImage

Robotic Process Automation

Let's talk about the solution provided by Microsoft for Robotic Process Automation (RPA)

secondImage

Community Highlights

Check out whats happening in Power Apps

secondImage

Community User Group Member Badges

FIll out a quick form to claim your community user group member badge today!

Top Solution Authors
Top Kudoed Authors
Users online (9,609)