mercredi 18 décembre 2019

Which snippet to use in Postman test to validate a part of a header value

Within the response of an API POST request the location is returned in the header as a key and a value build from 2 parts: URL path+unique id

Screenshot Postman header

I'd like to validate within the Postman test only the URL path of the value, because unique Id will be different after every new request.

Example of Location header value in the response:

api/v1/users/cbca75db-7d7d-4687-9aa0-c68f4rg46465/customers/EXXXXXXXXX/emailaddresses/5637454148

I'd like to validate only:

api/v1/users/cbca75db-7d7d-4687-9aa0-c68f4rg46465/customers/EXXXXXXXXX/emailaddresses/

So far i have:

    pm.response.to.have.header("Location");
    pm.response.to.be.header("Location", "api/v1/users/cbca75db-7d7d-4687-9aa0-c68f4rg46465/customers/E000088/emailaddresses");

But this is not 100% correct

Aucun commentaire:

Enregistrer un commentaire