How to pass body as text in chaining request?

I have a request where I save one field using pm.environment.set('key', value);

My next request is a Post Call where I send value as a text in body but when I pass body as {{value}} and set Postman dropdown to text, my request fails with error code 400.

I wonder if there is a way to send body as a text in chaining.

Your question may already have an answer on the community forum. Please search for related topics, and then read through the guidelines before creating a new topic.

your body has {{key}} actually, right?

I’d suggest simple test also to make sure things are working with with the value prior to introducing the env variables as well.

Opening the console (from lower left icon) is helpful in troubleshooting requests.

You can send a raw text body and reference a variable, this will get used within the request:

That’s using a global variable to it works the same with an environment variable.

Are you able to share an image of what you’re seeing in the app, please?

@dannydainton I tried with both pm.environment.set and pm.globals.set. It’s not reading Body when passed as text and my request accepts text only.




@jonsworkalias Yes, I did.
The API call goes through when Body is passed as text directly.
When I do chaining I noticed Postman don’t read {{body}} when passed as text during chaining. I have attached screenshots for reference.

You have 2 different Content-Type Headers set for the 2 requests.

The one that fails has text/plain and the one that goes through have application/x-www-form-urlencoded

Which one is it supposed to be?

Also, if you open/expand the request from the Postman Console, you will see what has been sent rather than using the code feature which would generate a snippet of code to be sent.

@dannydainton You were right. I was using text/plain header which is wrong. However, using the correct header too application/x-www-form-urlencoded didn’t fix the issue. Although, I am getting response but it is not what is supposed to be.
Basically, I am querying Solr. The request will go through without body too but the response will not have what I needed.

I think this is a bug with Postman itself.