Saturday, May 28, 2022

How to set Environment Variables from XML Response in Postman?

xml2Json() can be used to convert the API response from XML to JSON. Then, we can retrieve the values from the JSON string.

Sample Code:
let XMLToJSONResponse = xml2Json( responseBody ); 
pm.environment.set( “Id”, XMLToJSONResponse[ “CUSTOMER” ][ “ID” ] ); 
pm.environment.set( “FirstName”, XMLToJSONResponse[ “CUSTOMER” ][ “FIRSTNAME” ] ); 
pm.environment.set( “LastName”, XMLToJSONResponse[ “CUSTOMER” ][ “LASTNAME” ] );

No comments:

Post a Comment

Unable to view Lucidchart Shapes

When you open the Lucidchart document, it will not show all the shapes. You have to edit the document to view all the added and supported sh...