Sending request body using Postman Flow

I cannot figure out how to specify the (JSON) request body in a Send Request block. I am using postman flow to chain together API calls. I have a collection with these calls saved. I fire a GET request, parse the resulting body in a typescript EVAL block to modify some parameters and then I want to use the output of that as the request body of a PUT request.

When the flow fires off, it defaults to the request body in the saved request. I cannot get it to take the output of that EVAL block as the current request body and I thought maybe the right approach was to set a global variable inside the saved request’s body area {{someGlobal}} and then modify that global in the eval block.

Using the postman AI helper it says I should be able to use pm.globals.set() but that doesn’t work either.

Hi @asafp

Welcome to the forums!

The body of your put request should be just a variable {{body}} (or some other name). This will create a variable input in the send request block when it’s on the flows canvas. You can connect the output of your evaluate block to the input here and it will run with that value.

Just a note: Global variables don’t work with flows and the evaluate block doesn’t have access to pm functions.

I’m having trouble using one flow as a module in another flow. The request block in the flow that I’m using as a module contains a body that contains the variable {{payload}}. Additionally, the pre-request script in the API request does a few data operations.

Remarkably, when I use it directly, the flow functions properly; but, when I use it as a module, the error is: Failed to parse body.



Thank you. I think there may be some optimization of flows needed here. The blocks don’t seem to refresh properly. I had tried what you suggested prior to writing this question but the request block never showed the variable as an input option. I decided to see what would happen if I created a new global and sure enough once I created it, it seems to have triggered the refresh and suddenly all the variables (including my body one) showed up.

@asafp

I’m glad it’s working now. I will look into this, the blocks should refresh as soon as you save your request.