# How to convert integer value to string while in Pre-request script?

**URL:** <https://community.postman.com/t/how-to-convert-integer-value-to-string-while-in-pre-request-script/16311>\
**Category:** Help Hub\
**Tags:** collections\
**Created:** [September 29, 2020, 2:12am UTC](https://community.postman.com/t/how-to-convert-integer-value-to-string-while-in-pre-request-script/16311 "2020-09-29T02:12:32Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![bukhari.adac](https://avatars.discourse-cdn.com/v4/letter/b/c2a13f/32.png) [@bukhari.adac](https://community.postman.com/u/bukhari.adac)\
**Post date:** [September 29, 2020, 2:12am UTC](https://community.postman.com/t/how-to-convert-integer-value-to-string-while-in-pre-request-script/16311/1 "2020-09-29T02:12:32Z")

</div>

I want to post integer column value as string. Can you please help how to convert integer to string in the following example. This is posting last two column (Qty & price) value as integer instead of string.

columns in CSV file  
item\_id,title,bullets1,bullets2,bullets3,bullets4,bullets5,qty,price  
1234,men shoes,Textile,Rubber sole,Lace up closure,fabric lining, ,989,10

```auto
Pre-request script:

    const requestBody = {
        item_id: null,
        fields: []
    };

    for (let [key, value] of Object.entries(data)) {
        if (key.startsWith('bullets') || key === 'title') {
            if (value !== '') {
                requestBody.fields.push({
                    name: key,
                    value: value
                });
            }
        } else {
            requestBody[key] = value;
        }
    }

    pm.variables.set('requestBody', JSON.stringify(requestBody));

```

Thanks.

Adac

---

<div class="post-metadata">

**Author:** ![amit](https://sea2.discourse-cdn.com/getpostman/user_avatar/community.postman.com/amit/32/2056_2.png) [@amit](https://community.postman.com/u/amit)\
**Post date:** [September 29, 2020, 2:38am UTC](https://community.postman.com/t/how-to-convert-integer-value-to-string-while-in-pre-request-script/16311/2 "2020-09-29T02:38:59Z")

</div>

Hey @bukhari.adac, 👋

just change the lines where you are setting the value as following

```
value: "" + value;

```

and

```
requestBody[key] = "" + value;

```

That would covert the data inside `value` to a string before storing. Now when you to `JSON.stringify()` it will take care of adding the quotes around the value, since it’s a string now.

---

<div class="post-metadata">

**Author:** ![bukhari.adac](https://avatars.discourse-cdn.com/v4/letter/b/c2a13f/32.png) [@bukhari.adac](https://community.postman.com/u/bukhari.adac)\
**Post date:** [September 30, 2020, 3:06am UTC](https://community.postman.com/t/how-to-convert-integer-value-to-string-while-in-pre-request-script/16311/3 "2020-09-30T03:06:34Z")

</div>

Great, it worked. Thanks @amit.

I also want to know how to skip a specific column and its value while using collection runner, like **bullet3** in this particular example.
