# Data driven Approach

**URL:** <https://community.postman.com/t/data-driven-approach/15066>\
**Category:** Help Hub\
**Created:** [August 17, 2020, 8:54am UTC](https://community.postman.com/t/data-driven-approach/15066 "2020-08-17T08:54:13Z")\
**Posts on this page:** 7\
**Page:** 1

<div class="post-metadata">

**Author:** ![aakashjain8693](https://avatars.discourse-cdn.com/v4/letter/a/7c8e57/32.png) [@aakashjain8693](https://community.postman.com/u/aakashjain8693)\
**Post date:** [August 17, 2020, 8:54am UTC](https://community.postman.com/t/data-driven-approach/15066/1 "2020-08-17T08:54:13Z")

</div>

Hi Team,

I am using the `csv` file where I’m putting all data with respective fields.

a sample of the JSON response:

```auto
"rank": {

            "id": 0,

            "description": "OPTAVIA Coach"

        },

```

Now one of the values is `"OPTAVIA Coach"` for which I am making the script as

```auto
pm.test("data Verification", function () {
    var jsonData = pm.response.json();
pm.expect(jsonData[0].rank.description).to.eql(String(data.description));
});

```

But getting error as data Verification | AssertionError: expected ‘OPTAVIA Coach’ to deeply equal ‘OPTAVIA Coach’

Note: observed when string without space of special character, script working fine no issue.  
Any Solution for this?

---

<div class="post-metadata">

**Author:** ![aakashjain8693](https://avatars.discourse-cdn.com/v4/letter/a/7c8e57/32.png) [@aakashjain8693](https://community.postman.com/u/aakashjain8693)\
**Post date:** [August 17, 2020, 8:55am UTC](https://community.postman.com/t/data-driven-approach/15066/2 "2020-08-17T08:55:06Z")

</div>

@allenheltondev @singhsivcan @danny-dainton

---

<div class="post-metadata">

**Author:** ![allenheltondev](https://sea2.discourse-cdn.com/getpostman/user_avatar/community.postman.com/allenheltondev/32/31738_2.png) [@allenheltondev](https://community.postman.com/u/allenheltondev)\
**Post date:** [August 17, 2020, 11:31am UTC](https://community.postman.com/t/data-driven-approach/15066/3 "2020-08-17T11:31:54Z")

</div>

It might be the way you’re casting it to a string. Why don’t you try taking out the cast?

```auto
pm.test(“data Verification”, function () {
   var jsonData = pm.response.json();
   pm.expect(jsonData[0].rank.description).to.eql(data.description);
});

```

---

<div class="post-metadata">

**Author:** ![aakashjain8693](https://avatars.discourse-cdn.com/v4/letter/a/7c8e57/32.png) [@aakashjain8693](https://community.postman.com/u/aakashjain8693)\
**Post date:** [August 17, 2020, 11:37am UTC](https://community.postman.com/t/data-driven-approach/15066/4 "2020-08-17T11:37:45Z")

</div>

Tried but had no luck.Even tried with Number casting too but not working.

---

<div class="post-metadata">

**Author:** ![danny-dainton](https://sea2.discourse-cdn.com/getpostman/user_avatar/community.postman.com/danny-dainton/32/29401_2.png) [@danny-dainton](https://community.postman.com/u/danny-dainton)\
**Post date:** [August 17, 2020, 11:49am UTC](https://community.postman.com/t/data-driven-approach/15066/5 "2020-08-17T11:49:11Z")

</div>

Hey @aakashjain8693

What does the CSV file look like?

Can you add the full response body and not a sample of it please, it looks like something is missing and it would be easy to run it locally it it’s all there 😃

I’m not really sure what this is supposed to be doing in the expect statement:

```auto
String(data.description);

```

Have you tried referencing the data in the CSV file like this:

```auto
pm.expect(jsonData[0].rank.description).to.eql(pm.iterationData.get('<The CSV Column Name of the Value >'));

```

[https://learning.postman.com/docs/writing-scripts/script-references/postman-sandbox-api-reference/#pmiterationdata](https://learning.postman.com/docs/writing-scripts/script-references/postman-sandbox-api-reference/#pmiterationdata)

---

<div class="post-metadata">

**Author:** ![aakashjain8693](https://avatars.discourse-cdn.com/v4/letter/a/7c8e57/32.png) [@aakashjain8693](https://community.postman.com/u/aakashjain8693)\
**Post date:** [August 17, 2020, 11:58am UTC](https://community.postman.com/t/data-driven-approach/15066/6 "2020-08-17T11:58:55Z")

</div>

Response Body:

```auto
[

    {

        "id": "100067191",

        "customerTypeId": 2,

        "firstName": "Tanya R.",

        "lastName": "Smith",

        "nextScheduledPremierOrder": {

            "cv": null,

            "qv": null,

            "orderType": null,

            "scheduledOn": null,

            "price": {

                "total": null

            }

        },

        "rewards": {

            "balance": null

        },

        "rank": {

            "id": 0,

            "description": "OPTAVIA Coach"

        },

        "certified": "0",

        "licensed": "",

        "phoneNumber": "916-617-0194",

        "businessEmail": "tanchel60@hotmail.com",

        "accountEmail": "tanchel60@hotmail.com",

        "address": {

            "line1": "637 Fourness Dr",

            "line2": null,

            "city": "West Sacramento",

            "state": "US-AK",

            "postalCode": "95605-2223",

            "countryCode": "US-AK"

        },

        "socialAccounts": {

            "facebook": {

                "url": null,

                "username": null

            },

            "instagram": {

                "url": null,

                "username": null

            },

            "twitter": {

                "url": null,

                "username": null

            }

        },

        "highestAchievedRank": {

            "id": 0

        },

        "volume": {

            "pqv": "0.0000",

            "fqv": "0.0000",

            "gen0Qv": "0.0000",

            "gqv": "0.0000"

        },

        "activationOn": null,

        "businessCoach": {

            "id": "5",

            "firstName": "Company",

            "lastName": "Account",

            "rank": {

                "id": 70

            }

        },

        "globalDirector": {

            "id": "30118781",

            "firstName": "Paula",

            "lastName": "Bryan",

            "rank": {

                "id": 110

            }

        },

        "presidentialDirector": {

            "id": "2591401",

            "firstName": "Lisa",

            "lastName": "Castro",

            "rank": {

                "id": 140

            }

        },

        "earnedQsb": 0,

        "orderingEntitiesCount": 0

    }

]

```

```auto
pm.expect(jsonData[0].rank.description).to.eql(pm.iterationData.get('description'));
Tried but not working, error exist: expected 'OPTAVIA Coach' to deeply equal 'OPTAVIA Coach'

```

Sheet I cant attach but its very simple where as coulmn header as “description” and value as “OPTAVIA Coach”.

cc @gopagonirakesh98

---

<div class="post-metadata">

**Author:** ![aakashjain8693](https://avatars.discourse-cdn.com/v4/letter/a/7c8e57/32.png) [@aakashjain8693](https://community.postman.com/u/aakashjain8693)\
**Post date:** [August 18, 2020, 4:26am UTC](https://community.postman.com/t/data-driven-approach/15066/7 "2020-08-18T04:26:49Z")

</div>

Thanks @danny-dainton for the solution.  
Solution: Basically few string values contains some other characters which were hidden in .csv file but you can see them on atom so just remove them and try again, it will work.
