# Postman is cutting off my variables

**URL:** <https://community.postman.com/t/postman-is-cutting-off-my-variables/53619>\
**Category:** Help Hub\
**Tags:** postman-flows\
**Created:** [October 23, 2023, 6:15pm UTC](https://community.postman.com/t/postman-is-cutting-off-my-variables/53619 "2023-10-23T18:15:43Z")\
**Posts on this page:** 6\
**Page:** 1

<div class="post-metadata">

**Author:** ![material-astronomer4](https://sea2.discourse-cdn.com/getpostman/user_avatar/community.postman.com/material-astronomer4/32/26270_2.png) [@material-astronomer4](https://community.postman.com/u/material-astronomer4)\
**Post date:** [October 23, 2023, 6:15pm UTC](https://community.postman.com/t/postman-is-cutting-off-my-variables/53619/1 "2023-10-23T18:15:44Z")

</div>

This is the exact scenario.  
I make a GET request that returns a list (you can see on the image, there are 15 elements inside body.data.contents:

 ![Screenshot 2023-10-23 at 15.04.33](https://us1.discourse-cdn.com/getpostman/original/3X/8/2/822cb9e44a0501830b24a5cc31374cfd89de0fee.png)

I can see the response on the output, that’s fine.  
Then i have a FOR with that list:  
and flows make a Request (POST) per item, to include some variables from the list:

 ![Screenshot 2023-10-23 at 15.06.33](https://us1.discourse-cdn.com/getpostman/original/3X/6/5/652e0203eb7cd0c39148926fdef0effaa194056d.png)

And then i have the 400 error.  
When i see the logs on the console, i realize that the _content_ variable is being cutted off by Postman. Does it matter if it’s a HTML variable? i really don’t think that’s the issue.  
This is the problem (based on the console log of the request):

 ![Screenshot 2023-10-23 at 15.07.40](https://us1.discourse-cdn.com/getpostman/original/3X/f/4/f47312a6e3b5f424688a5a249a49b68276fb3e8c.png)

> \<a href="https:

Then, the new line is the next variable, so there is no double quote to end the content parameter. Then, there is an error on my JSON.

Also, if you check the request, there is no error on it

```auto
{
    "opportunityId": {{opportunityIdTo}},
    "attributeType": "text",
    "order": {{order}},
    "alignment": "none",
    "side": "left",
    "title": "{{title}}",
    "content": "{{content}}",
    "saving": true,
    "language": "EN"
}

```

And on the output, i can see the entire variable in a single line.  
So there is no cutting on my side!

## **Platform Details** :

### Postman for Mac

Version10.19.0  
UI version: 10.19.0-ui-230919-1303  
Desktop platform version: 10.19.0  
Architecture: arm64  
OS platform: OS X 23.0.0

- **Tags** : Postman Flows,

---

<div class="post-metadata">

**Author:** ![kevinc-postman](https://sea2.discourse-cdn.com/getpostman/user_avatar/community.postman.com/kevinc-postman/32/12774_2.png) [@kevinc-postman](https://community.postman.com/u/kevinc-postman)\
**Post date:** [October 23, 2023, 9:27pm UTC](https://community.postman.com/t/postman-is-cutting-off-my-variables/53619/2 "2023-10-23T21:27:56Z")

</div>

Hi @material-astronomer4

Thank you so much for the very clean and detailed description of the issue you’re encountering. I wish others were as detailed as this as well 😅

At first glance, I’m thinking that character escaping may be the issue at hand here. The double quotes would normally need to be properly escaped and when we throw in the slashes, it ends up being cut off like that.

A few other _possible_ issues could be:

1. **Payload Size** : Check if the size of the `POST` payload is within the acceptable limits for both Postman and the API endpoint you’re hitting.
2. **Headers and Content-Type** : Ensure that the headers, especially the `Content-Type`, are set correctly for the POST request. If the content is being sent as JSON, make sure the header is `application/json`.

Some potential workarounds could include:

- Use Postman’s built-in functions to stringify the JSON object, which will automatically handle the character escaping. For example:

```js
let contentData = {
 content: "<a href=\"https://example.com\">Link</a>"
};
pm.request.body.update(JSON.stringify(contentData));

```

- Try breaking the `content` variable into smaller chunks and ensure that each chunk is sent correctly. This can help narrow down the specific point or character that might be causing the issue.
- Use a tool like [Base64](https://www.base64encode.org/) to encode the `content` string and then decode it on the server-side. This can help bypass any issues related to special characters.

---

<div class="post-metadata">

**Author:** ![material-astronomer4](https://sea2.discourse-cdn.com/getpostman/user_avatar/community.postman.com/material-astronomer4/32/26270_2.png) [@material-astronomer4](https://community.postman.com/u/material-astronomer4)\
**Post date:** [October 24, 2023, 1:12am UTC](https://community.postman.com/t/postman-is-cutting-off-my-variables/53619/3 "2023-10-24T01:12:45Z")

</div>

Thanks @kevinc-postman for your soon answer.

Doing more research i could found there are some new lines on the string.  
And, not sure why, but Postman is just sending the first row.  
I use to use a function on Postman request \> Test like this:

` data = data.replace(/(\r\n|\n|\r)/gm, "");`

What’s the way to remove new lines and then use the variable in another method?

---

<div class="post-metadata">

**Author:** ![kevinc-postman](https://sea2.discourse-cdn.com/getpostman/user_avatar/community.postman.com/kevinc-postman/32/12774_2.png) [@kevinc-postman](https://community.postman.com/u/kevinc-postman)\
**Post date:** [October 24, 2023, 5:03pm UTC](https://community.postman.com/t/postman-is-cutting-off-my-variables/53619/4 "2023-10-24T17:03:57Z")

</div>

There’s a few ways you can do this that I can think of right now.

The [evaluate block](https://learning.postman.com/docs/postman-flows/reference/blocks-list/#evaluate) in Flows would allow you to sanitize the string before it’s passed to the POST request. Something like your regex should work fine there and [Postbot](https://learning.postman.com/docs/getting-started/basics/about-postbot/) can help you with writing the FQL if you get stuck 🙂

Another would be to write the test script manually outside of flows on the request itself, and storing it as an environment variable to [use in your Flow](https://learning.postman.com/docs/postman-flows/reference/blocks-list/#get-variable).

---

<div class="post-metadata">

**Author:** ![material-astronomer4](https://sea2.discourse-cdn.com/getpostman/user_avatar/community.postman.com/material-astronomer4/32/26270_2.png) [@material-astronomer4](https://community.postman.com/u/material-astronomer4)\
**Post date:** [October 31, 2023, 5:18pm UTC](https://community.postman.com/t/postman-is-cutting-off-my-variables/53619/5 "2023-10-31T17:18:16Z")

</div>

i can make it works, using $trim(variable).  
My current problem is sending JSON data, with string values, Postman is cutting with double quotes like here:  
 ![Screenshot 2023-10-30 at 17.41.18](https://us1.discourse-cdn.com/getpostman/original/3X/e/7/e7d66f0c72d41230b37369d12873511f92f4bf99.png)  
where there is a:

```auto
"content":"<div <p class="mb-2">.... 

```

As you can see with colors, there is a black and then red color, so postman is cutting the content.  
I am trying to fixing this, but i guess this should be an internal bug, because if you see this flow:

 ![Screenshot 2023-10-31 at 14.17.22](https://us1.discourse-cdn.com/getpostman/original/3X/9/a/9abf110c4a4560daf56ba1e91c386c5126c11df8.png)  
i get the content variable, i trim it, remove new lines, and then send it as parameter to a new request.

Should Postman Flows escape it on your end?

---

<div class="post-metadata">

**Author:** ![system](https://sea2.discourse-cdn.com/getpostman/user_avatar/community.postman.com/system/32/29796_2.png) [@system](https://community.postman.com/u/system)\
**Post date:** [November 30, 2023, 5:18pm UTC](https://community.postman.com/t/postman-is-cutting-off-my-variables/53619/6 "2023-11-30T17:18:33Z")

</div>

Closed on November 30, 2023, 5:18pm UTC

This topic was automatically closed 30 days after the last reply. New replies are no longer allowed.
