jeudi 2 août 2018

JSON schema validation error - postman

JSON file response body :

{
    "Concurr": {
        "BPhoneNumber": null,
        "Agility": 1,
        "Email": "abcde@gg.com",
        "FirstName": "DIK",
        "LastName": "BO",
        "PhoneNumber": "03456778",
        "PhoneType": "",
        "PostalAddress": {
            "Address1": "47 ILZ RUE KLI EBRELES",
            "Address2": null,
            "Address3": null,
            "City": "OOL",
            "Country": "250",
            "Zip": "9760"
        },
        "PNSCode": ""
    },
    "DealID": 2,
    "ObjID": null,
    "OrderM": "IOPL",
    "Parts": [],
    "Product": {
        "ComRef": "IKOL341JKL        ",
        "PurchaseDate": "2018-07-12T06:31:13.053",
        "SerialNumber": "9501123456",
        "TRef": "S51M50X2EU/03"
    },
    "StNas": [
        {
            "AppointmentDate": "2018-08-02T10:03:27.8737443+02:00",
            "AppointmentRank": null,
            "Code": "100",
            "Comment": "",
            "Parts": []
        },
        {
            "AppointmentDate": "2018-08-02T10:03:27.8737443+02:00",
            "AppointmentRank": null,
            "Code": "1101",
            "Comment": "",
            "Parts": []
        }
    ],
    "SCode": null,
    "VID": 10
}

after generating the schema via https://jsonschema.net I am validating the schema using this

var data = JSON.parse(responseBody);
tests["Valid scehma"] = tv4.validate(data, schema);

This always provides me error in Postman as

There was an error in evaluating the test script : Cannot read property 'id' of null

Could anybody help in understanding or has any solution regarding the issue as to what leads to this error / any help is appreciated

Aucun commentaire:

Enregistrer un commentaire