How to validate response in Postman?

前端 未结 1 619
既然无缘
既然无缘 2020-12-22 06:16

I am trying to validate response body including errors in postman. How can I validate the response and text below?

{
    \"responseHeader\": {
        \"publ         


        
相关标签:
1条回答
  • 2020-12-22 06:44

    In the "Test" tab, parse your response body into an object, then use JavaScript to perform your tests.

    var data = JSON.parse(responseBody);
    tests["publisherId is 12345"] = data.responseHeader.publisherId === "12345";
    

    Take a look at the test examples at the Postman site:

    https://www.getpostman.com/docs/postman/scripts/test_scripts

    https://www.getpostman.com/docs/postman/scripts/test_examples

    0 讨论(0)
提交回复
热议问题