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

Resize image in Mac OS

How to Easily Resize an Image on Mac Using Preview Ever tried to upload a photo to a website only to be told the file is too large? Or maybe...