Postman is cutting off my variables

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:

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:

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

<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

{
    "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,

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 :sweat_smile:

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:
    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 to encode the content string and then decode it on the server-side. This can help bypass any issues related to special characters.

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?

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

The evaluate block 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 can help you with writing the FQL if you get stuck :slight_smile:

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.

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
where there is a:

"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:


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?

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