Magento Postman Soap Login get sesssionId in Pre-request Script

I can use pm.sendRequest to make an XML request.

For example with magento to use soap I have to login to receive an id session

url magento request soap


    <Envelope xmlns="">
            <login xmlns="urn:Magento">


        <loginReturn xsi:type="xsd:string">8292295363d53a2ca209dc4a8457da77</loginReturn>

can I create a pre-request script using pm.sendRequest, pars the answer and just take the session id (loginReturn) to insert in another request (doing it all in one step)?

In Tests tab

var responseJson = xml2Json(responseBody);
postman.setEnvironmentVariable("sessionId", responseJson['SOAP-ENV:Envelope']['SOAP-ENV:Body']['ns1:loginResponse']['loginReturn']['_']);
  • It will set sessionId variable within environment and you can use it for other calls {{sessionId}}