3 just some formatting
source | link

When submitting an order to an API we get a Json response containing:

"AMLResults": [
    {
        "amlResult": [
            {
                "addresses": [
                    {
                        "flatNo": "Flat 1",
                        "houseNumber": "32",
                        "line1": "Ayr Street",
                        "line2": "",
                        "town": "GLASGOW",
                        "postcode": "G21 4DG"
                    }

And then I'm trying to test that the address is returned and formatted correctly

let amlResult = {};
pm.test("response should contain a formated client address",function(){
jsonData = pm.response.json();
pm.expect(amlResult).to.have.property('addresses');
addresses = amlResult.addresses;
    pm.expect(addresses).to.have.property('flatNo', 'Flat 1');
    pm.expect(addresses).to.have.property('houseNumber', '32');
    pm.expect(addresses).to.have.property('line1', 'Ayr Street');
    pm.expect(addresses).to.have.property('line2', '');
    pm.expect(addresses).to.have.property('town', 'GLASGOW');
    pm.expect(addresses).to.have.property('postcode', 'G21 4DG');
});

});

However I keep getting the following failure response:

response should contain a formated client address | AssertionError: expected {} to have property 'addresses'

Any help would be appreciated.

When submitting an order to an API we get a Json response containing:

"AMLResults": [
    {
        "amlResult": [
            {
                "addresses": [
                    {
                        "flatNo": "Flat 1",
                        "houseNumber": "32",
                        "line1": "Ayr Street",
                        "line2": "",
                        "town": "GLASGOW",
                        "postcode": "G21 4DG"
                    }

And then I'm trying to test that the address is returned and formatted correctly

let amlResult = {};
pm.test("response should contain a formated client address",function(){
jsonData = pm.response.json();
pm.expect(amlResult).to.have.property('addresses');
addresses = amlResult.addresses;
pm.expect(addresses).to.have.property('flatNo', 'Flat 1');
pm.expect(addresses).to.have.property('houseNumber', '32');
pm.expect(addresses).to.have.property('line1', 'Ayr Street');
pm.expect(addresses).to.have.property('line2', '');
pm.expect(addresses).to.have.property('town', 'GLASGOW');
pm.expect(addresses).to.have.property('postcode', 'G21 4DG');

});

However I keep getting the following failure response:

response should contain a formated client address | AssertionError: expected {} to have property 'addresses'

Any help would be appreciated.

When submitting an order to an API we get a Json response containing:

"AMLResults": [
    {
        "amlResult": [
            {
                "addresses": [
                    {
                        "flatNo": "Flat 1",
                        "houseNumber": "32",
                        "line1": "Ayr Street",
                        "line2": "",
                        "town": "GLASGOW",
                        "postcode": "G21 4DG"
                    }

And then I'm trying to test that the address is returned and formatted correctly

let amlResult = {};
pm.test("response should contain a formated client address",function(){
jsonData = pm.response.json();
pm.expect(amlResult).to.have.property('addresses');
addresses = amlResult.addresses;
    pm.expect(addresses).to.have.property('flatNo', 'Flat 1');
    pm.expect(addresses).to.have.property('houseNumber', '32');
    pm.expect(addresses).to.have.property('line1', 'Ayr Street');
    pm.expect(addresses).to.have.property('line2', '');
    pm.expect(addresses).to.have.property('town', 'GLASGOW');
    pm.expect(addresses).to.have.property('postcode', 'G21 4DG');
});

However I keep getting the following failure response:

response should contain a formated client address | AssertionError: expected {} to have property 'addresses'

Any help would be appreciated.

2 edited tags
| link
1
source | link

How to identify a specific location in returned Json through a postman test

When submitting an order to an API we get a Json response containing:

"AMLResults": [
    {
        "amlResult": [
            {
                "addresses": [
                    {
                        "flatNo": "Flat 1",
                        "houseNumber": "32",
                        "line1": "Ayr Street",
                        "line2": "",
                        "town": "GLASGOW",
                        "postcode": "G21 4DG"
                    }

And then I'm trying to test that the address is returned and formatted correctly

let amlResult = {};
pm.test("response should contain a formated client address",function(){
jsonData = pm.response.json();
pm.expect(amlResult).to.have.property('addresses');
addresses = amlResult.addresses;
pm.expect(addresses).to.have.property('flatNo', 'Flat 1');
pm.expect(addresses).to.have.property('houseNumber', '32');
pm.expect(addresses).to.have.property('line1', 'Ayr Street');
pm.expect(addresses).to.have.property('line2', '');
pm.expect(addresses).to.have.property('town', 'GLASGOW');
pm.expect(addresses).to.have.property('postcode', 'G21 4DG');

});

However I keep getting the following failure response:

response should contain a formated client address | AssertionError: expected {} to have property 'addresses'

Any help would be appreciated.