cancel
Showing results for 
Search instead for 
Did you mean: 
Reply
Highlighted
livingstonep
Level 8

Parse JSON step failing with null error

we are getting an error parsing JSON from an HTTP Get request in our flow.

 

Here is the schema we are using in our Parse JSON step:

{
    "type": "object",
    "properties": {
        "d": {
            "type": "object",
            "properties": {
                "results": {
                    "type": "array",
                    "items": {
                        "type": "object",
                        "properties": {
                            "__metadata": {
                                "type": "object",
                                "properties": {
                                    "id": {
                                        "type": "string"
                                    },
                                    "uri": {
                                        "type": "string"
                                    },
                                    "type": {
                                        "type": "string"
                                    }
                                }
                            },
                            "Alerts": {
                                "type": "object",
                                "properties": {
                                    "__deferred": {
                                        "type": "object",
                                        "properties": {
                                            "uri": {
                                                "type": "string"
                                            }
                                        }
                                    }
                                }
                            },
                            "Groups": {
                                "type": "object",
                                "properties": {
                                    "__deferred": {
                                        "type": "object",
                                        "properties": {
                                            "uri": {
                                                "type": "string"
                                            }
                                        }
                                    }
                                }
                            },
                            "Id": {
                                "type": "integer"
                            },
                            "IsHiddenInUI": {
                                "type": "boolean"
                            },
                            "LoginName": {
                                "type": "string"
                            },
                            "Title": {
                                "type": "string"
                            },
                            "PrincipalType": {
                                "type": "integer"
                            },
                            "Email": {
                                "type": "string"
                            },
                            "IsEmailAuthenticationGuestUser": {
                                "type": "boolean"
                            },
                            "IsShareByEmailGuestUser": {
                                "type": "boolean"
                            },
                            "IsSiteAdmin": {
                                "type": "boolean"
                            },
                            "UserId": {
                                "type": "object",
                                "properties": {
                                    "__metadata": {
                                        "type": "object",
                                        "properties": {
                                            "type": {
                                                "type": "string"
                                            }
                                        }
                                    },
                                    "NameId": {
                                        "type": "string"
                                    },
                                    "NameIdIssuer": {
                                        "type": "string"
                                    }
                                }
                            }
                        },
                        "required": [
                            "__metadata",
                            "Alerts",
                            "Groups",
                            "Id",
                            "IsHiddenInUI",
                            "LoginName",
                            "Title",
                            "PrincipalType",
                            "Email",
                            "IsEmailAuthenticationGuestUser",
                            "IsShareByEmailGuestUser",
                            "IsSiteAdmin",
                            "UserId"
                        ]
                    }
                }
            }
        }
    }
}

we are only interested in the Email property that we want to use to send approvals...

 

here are the INPUTS results of the Parse JSON step that fails:

{
  "d": {
    "results": [
      {
        "__metadata": {
          "id": "https://*********.sharepoint.com/_api/Web/GetUserById(1691)",
          "uri": "https://*********.sharepoint.com/_api/Web/GetUserById(1691)",
          "type": "SP.User"
        },
        "Alerts": {
          "__deferred": {
            "uri": "https://*********.sharepoint.com/_api/Web/GetUserById(1691)/Alerts"
          }
        },
        "Groups": {
          "__deferred": {
            "uri": "https://*********.sharepoint.com/_api/Web/GetUserById(1691)/Groups"
          }
        },
        "Id": 1691,
        "IsHiddenInUI": false,
        "LoginName": "i:0#.f|membership|Surnamei@Company.org.uk",
        "Title": "Firstname Surname",
        "PrincipalType": 1,
        "Email": "Surnamef@Company.org.uk",
        "Expiration": "",
        "IsEmailAuthenticationGuestUser": false,
        "IsShareByEmailGuestUser": false,
        "IsSiteAdmin": false,
        "UserId": {
          "__metadata": {
            "type": "SP.UserIdInfo"
          },
          "NameId": "10033fff9fe67a30",
          "NameIdIssuer": "urn:federation:microsoftonline"
        },
        "UserPrincipalName": "Surnamef@Company.org.uk"
      },
      }
    ]
  }

here is the schema from the run results of the Parse JSON that fails:

{
  "type": "object",
  "properties": {
    "d": {
      "type": "object",
      "properties": {
        "results": {
          "type": "array",
          "items": {
            "type": "object",
            "properties": {
              "__metadata": {
                "type": "object",
                "properties": {
                  "id": {
                    "type": "string"
                  },
                  "uri": {
                    "type": "string"
                  },
                  "type": {
                    "type": "string"
                  }
                }
              },
              "Alerts": {
                "type": "object",
                "properties": {
                  "__deferred": {
                    "type": "object",
                    "properties": {
                      "uri": {
                        "type": "string"
                      }
                    }
                  }
                }
              },
              "Groups": {
                "type": "object",
                "properties": {
                  "__deferred": {
                    "type": "object",
                    "properties": {
                      "uri": {
                        "type": "string"
                      }
                    }
                  }
                }
              },
              "Id": {
                "type": "integer"
              },
              "IsHiddenInUI": {
                "type": "boolean"
              },
              "LoginName": {
                "type": "string"
              },
              "Title": {
                "type": "string"
              },
              "PrincipalType": {
                "type": "integer"
              },
              "Email": {
                "type": "string"
              },
              "IsEmailAuthenticationGuestUser": {
                "type": "boolean"
              },
              "IsShareByEmailGuestUser": {
                "type": "boolean"
              },
              "IsSiteAdmin": {
                "type": "boolean"
              },
              "UserId": {
                "type": "object",
                "properties": {
                  "__metadata": {
                    "type": "object",
                    "properties": {
                      "type": {
                        "type": "string"
                      }
                    }
                  },
                  "NameId": {
                    "type": "string"
                  },
                  "NameIdIssuer": {
                    "type": "string"
                  }
                }
              }
            },
            "required": [
              "__metadata",
              "Alerts",
              "Groups",
              "Id",
              "IsHiddenInUI",
              "LoginName",
              "Title",
              "PrincipalType",
              "Email",
              "IsEmailAuthenticationGuestUser",
              "IsShareByEmailGuestUser",
              "IsSiteAdmin",
              "UserId"
            ]
          }
        }
      }
    }
  }
}

and here is the erro in the step from the run history:

[
  {
    "message": "Invalid type. Expected Object but got Null.",
    "lineNumber": 0,
    "linePosition": 0,
    "path": "d.results[3].UserId",
    "schemaId": "#/properties/d/properties/results/items/properties/UserId",
    "errorType": "type",
    "childErrors": []
  }
]

so how can I change the schema to successfully retrieve the email

1 ACCEPTED SOLUTION

Accepted Solutions
Super User
Super User

Re: Parse JSON step failing with null error

Hi @livingstonep 

 

So apply to each on body('httpactionname')?['d']?['results']

 

and then within the loop use

item()?['Email']

 

Regards,

Reza Dorrani

 

If this post helps, then please consider Accept it as the solution to help the other members find it more quickly

 

 

View solution in original post

4 REPLIES 4
Super User
Super User

Re: Parse JSON step failing with null error

Hi @livingstonep 

 

Use 

body('httpactionname')?['d']?['results']?[0]?['Email']

 

Regards,

Reza Dorrani

 

If this post helps, then please consider Accept it as the solution to help the other members find it more quickly

livingstonep
Level 8

Re: Parse JSON step failing with null error

after investigating the group a bit and the JSON, we tried:

 

_api/web/sitegroups/getbyname('Legal Owners')/users?$filter=UserId+ne+null

as the body of the HTTP Get and it worked...

livingstonep
Level 8

Re: Parse JSON step failing with null error


@RezaDorrani wrote:

Hi @livingstonep 

 

Use 

body('httpactionname')?['d']?['results']?[0]?['Email']

 

Regards,

Reza Dorrani

 

If this post helps, then please consider Accept it as the solution to help the other members find it more quickly


hi,

 

Thanks but we are using an Apply to Each control steop to loop through all the users in the group and send an approval to each one...

 

would that still work - we are parsing the JSON in order to get the list...

 

so how could I implement your suggestion in a loop?

Super User
Super User

Re: Parse JSON step failing with null error

Hi @livingstonep 

 

So apply to each on body('httpactionname')?['d']?['results']

 

and then within the loop use

item()?['Email']

 

Regards,

Reza Dorrani

 

If this post helps, then please consider Accept it as the solution to help the other members find it more quickly

 

 

View solution in original post

Helpful resources

Announcements
firstImage

Microsoft Business Applications Virtual Launch Event

Watch the event on demand for an in-depth look at the new innovations across Dynamics 365 and the Microsoft Power Platform.

firstImage

Watch Sessions On Demand!

Continue your learning in our online communities.

Power Platform 2019 Release Wave 2 Plan

Power Platform 2019 Release Wave 2 Plan

Features releasing from October 2019 through March 2020.

thirdimage

Flow Community User Group Member Badge

Fill out a quick form to claim your user group badge now!

fifthimage

Microsoft Learn

Learn how to build the business apps that you need.

sixthImage

Power Platform World Tour

Find out where you can attend!

seventhimage

Webinars & Video Gallery

Watch & learn from the Flow Community Video Gallery!

Top Kudoed Authors
Users Online
Currently online: 453 members 4,278 guests
Recent signins:
Please welcome our newest community members: