How to extract a specific value from a Request Body in POSTMAN and save in a variable

Is there any way to get a specific value ( type="Bank_Application_LOAN_JP_Answer" ) from the Request body and save in a variable in postman?

Request Body

query_xml: "<ROWDATA type="Bank_Application_LOAN_JP">
<DateTime><![CDATA[01/03/2010 14:57:42]]></DateTime>
<Participient ID="1110">

I’ve been using this

let rowdataType = xml2Json(pm.request.body.raw);
pm.environment.set('rowdataType', rowdataType.type);


Similar post is discussed in this thread. In the query of the post the user mentioned a way to your question.

You can use $, something like


It’s a guess based on the response you have provided. Please tweak it based on your request, also try exploring cheerio. Let us know if there’s still an issue to get the value :slightly_smiling_face:

Hi @bpricilla , thank you for your answer.
I have tried but the problem is actual. I can not to get the mentioned value from request body.

Hello @harutharut,

Okay I get that, it should also work the same way as response. You cannot directly access the object using .type as in JSON.

How do you parse the response here? It’s the same. Just assign it to a different variable than responseBody.

Please try this:

const request = xml2Json(pm.request.body.raw);
var rowdataType = request['ROWDATA'].$['type']
pm.environment.set('rowdataType', rowdataType);

I am throwing this path based on the request body you have mentioned. Please tweak based on your path :slightly_smiling_face:

Else I would need the complete request :blush:

maybe I should write pre-request script for getting that value? :slight_smile:

let me show you the result.

@harutharut Are you using that variable “rowdataType” in the same request body as input/parameter?

If so, then you are right, it should go in pre-request script section :blush:

const requestBody = xml2Json(pm.request.body.raw);
var rowdataType = requestBody['ROWDATA'].$['type']
pm.environment.set('rowdataType', rowdataType);

I have update similar example in one of public workspace collection.

Hi @bpricilla , how are you?)

Is strange, but again no result.
I sent request and set pre-request script, but again get error

TypeError: Cannot read property 'ROWDATA' of undefined
1 Like

@harutharut , I am good thank you :blush: Hope you are safe too!!

I am sorry, I can’t assume things here, shall we connect please?

Drop me a message in LinkedIn.

ok, I have sent you connection request in Linkedin.

1 Like

Based on our discussion your request type is not raw, it is “x-www-form-urlencoded”.

so try this snippet,


Similar to this topic.

You can refer this link for more details.

@harutharut It’s all the same details we discussed yesterday, sharing it here so that it might be useful for someone in future :blush:

Please let me know if there’s still any issue.

Hi @bpricilla , thank you for your reply.
Yes, my request type is “x-www-form-urlencoded”.
At this moment, I have done a filter on all the parameters to show only ones that don’t have “disabled: true”
So I have an object and want to have access to the type. Could you help me to find shortest way? :slight_smile:

I found the solution and want to share here, maybe it can be useful for someone)
In my case I had several “x-www-form-urlencoded” key-values(rows). This snippet

const requestBody = xml2Json(pm.request.body.urlencoded);

can’t parse request body, and I had to filter before parsing. Let me show that part below

var params = pm.request.body.urlencoded.filter(function (param) {
    return param.disabled !== true;

const requestBody = xml2Json(params[0].value);
var rowdataType = requestBody['ROWDATA'].$['type']
pm.environment.set('rowdataType', rowdataType);
1 Like

Thanks for sharing the working snippet @harutharut :clap:

1 Like