cancel
Showing results for 
Search instead for 
Did you mean: 
Reply
stinsora
Regular Visitor

JSON Parse Error

I am experiencing a validation error on my JSON Parse step and I'm not sure where my error exists.

 

ValidationFailed. The schema validation failed.

 

Schema:

 

{
  "type": "object",
  "properties": {
    "data": {
      "type": "array",
      "items": {
        "type": "object",
        "properties": {
          "variant_id": {
            "type": "integer"
          },
          "location_id": {
            "type": "integer"
          },
          "reorder_point": {
            "type": "string"
          },
          "average_cost": {
            "type": "string"
          },
          "value_in_stock": {
            "type": "string"
          },
          "quantity_in_stock": {
            "type": "string"
          },
          "quantity_committed": {
            "type": "string"
          },
          "quantity_expected": {
            "type": "string"
          },
          "quantity_missing_or_excess": {
            "type": "string"
          }
        },
        "required": [
          "variant_id",
          "location_id",
          "reorder_point",
          "average_cost",
          "value_in_stock",
          "quantity_in_stock",
          "quantity_committed",
          "quantity_expected",
          "quantity_missing_or_excess"
        ]
      }
    }
  }
}

 

 

Content:

 

{
  "data": [
    {
      "variant_id": 6861410,
      "location_id": 28299,
      "reorder_point": "0.00000",
      "average_cost": "0.0721608936",
      "value_in_stock": "3391.5620000000",
      "quantity_in_stock": "47000.00000",
      "quantity_committed": "0.00000",
      "quantity_expected": "180000.00000",
      "quantity_missing_or_excess": "227000.00000"
    },
    {
      "variant_id": 6861411,
      "location_id": 28299,
      "reorder_point": "0.00000",
      "average_cost": "0.0326992683",
      "value_in_stock": "2681.3400000000",
      "quantity_in_stock": "82000.00000",
      "quantity_committed": "0.00000",
      "quantity_expected": "180000.00000",
      "quantity_missing_or_excess": "262000.00000"
    }
  ]
}

 

 

Error Output:

 

[
  {
    "message": "Invalid type. Expected String but got Null.",
    "lineNumber": 0,
    "linePosition": 0,
    "path": "data[21].average_cost",
    "schemaId": "#/properties/data/items/properties/average_cost",
    "errorType": "type",
    "childErrors": []
  },
  {
    "message": "Invalid type. Expected String but got Null.",
    "lineNumber": 0,
    "linePosition": 0,
    "path": "data[22].average_cost",
    "schemaId": "#/properties/data/items/properties/average_cost",
    "errorType": "type",
    "childErrors": []
  },
  {
    "message": "Invalid type. Expected String but got Null.",
    "lineNumber": 0,
    "linePosition": 0,
    "path": "data[24].average_cost",
    "schemaId": "#/properties/data/items/properties/average_cost",
    "errorType": "type",
    "childErrors": []
  },
  {
    "message": "Invalid type. Expected String but got Null.",
    "lineNumber": 0,
    "linePosition": 0,
    "path": "data[26].average_cost",
    "schemaId": "#/properties/data/items/properties/average_cost",
    "errorType": "type",
    "childErrors": []
  }
]

 

 

Thank you for your help.

1 ACCEPTED SOLUTION

Accepted Solutions
v-bofeng-msft
Community Support
Community Support

Hi @stinsora :

The key is that there may be records in your content where the value of the "average_cost" field is empty.

Please try this schema:

 

{
    "type": "object",
    "properties": {
        "data": {
            "type": "array",
            "items": {
                "type": "object",
                "properties": {
                    "variant_id": {
                        "type": "integer"
                    },
                    "location_id": {
                        "type": "integer"
                    },
                    "reorder_point": {
                        "type": "string"
                    },
                    "average_cost": {},
                    "value_in_stock": {
                        "type": "string"
                    },
                    "quantity_in_stock": {
                        "type": "string"
                    },
                    "quantity_committed": {
                        "type": "string"
                    },
                    "quantity_expected": {
                        "type": "string"
                    },
                    "quantity_missing_or_excess": {
                        "type": "string"
                    }
                },
                "required": [
                    "variant_id",
                    "location_id",
                    "reorder_point",
                    "average_cost",
                    "value_in_stock",
                    "quantity_in_stock",
                    "quantity_committed",
                    "quantity_expected",
                    "quantity_missing_or_excess"
                ]
            }
        }
    }
}

 

I think this link will help you a lot:

A Thesis on the Parse JSON action in Microsoft Flow(Problem 4 - null value properties)

 

Best Regards,

Bof

View solution in original post

2 REPLIES 2
v-bofeng-msft
Community Support
Community Support

Hi @stinsora :

The key is that there may be records in your content where the value of the "average_cost" field is empty.

Please try this schema:

 

{
    "type": "object",
    "properties": {
        "data": {
            "type": "array",
            "items": {
                "type": "object",
                "properties": {
                    "variant_id": {
                        "type": "integer"
                    },
                    "location_id": {
                        "type": "integer"
                    },
                    "reorder_point": {
                        "type": "string"
                    },
                    "average_cost": {},
                    "value_in_stock": {
                        "type": "string"
                    },
                    "quantity_in_stock": {
                        "type": "string"
                    },
                    "quantity_committed": {
                        "type": "string"
                    },
                    "quantity_expected": {
                        "type": "string"
                    },
                    "quantity_missing_or_excess": {
                        "type": "string"
                    }
                },
                "required": [
                    "variant_id",
                    "location_id",
                    "reorder_point",
                    "average_cost",
                    "value_in_stock",
                    "quantity_in_stock",
                    "quantity_committed",
                    "quantity_expected",
                    "quantity_missing_or_excess"
                ]
            }
        }
    }
}

 

I think this link will help you a lot:

A Thesis on the Parse JSON action in Microsoft Flow(Problem 4 - null value properties)

 

Best Regards,

Bof

View solution in original post

Thank you @v-bofeng-msft for the solution and the link. 😀

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.

R2 (Green) 768 x 460px.png

Microsoft Dynamics 365 & Power Platform User Professionals

DynamicsCon is a FREE, 4 half-day virtual learning experience for 11,000+ Microsoft Business Application users and professionals.

Top Solution Authors
Users online (2,928)