Personally, I still go for 2) Generate 'Code' button/link as it allows me to see the variables without actually having to send. Postman Console also includes the whole response, you just have to expand some entries to find it. Since the double-brace syntax is not valid JavaScript, we use the pm.variables.get() function to access the id variable.įinally, let’s save the changes as we’ve done before. See below for full details on each option. console.log ('key ' + key) console.log ('value ' + value) And then open up the Postman console (Cmd + Option + C / Ctrl + Alt + C) to view the debugs logs in a different window. Here is what i have in me pre-request script: pm.t(transactionIdNr, pm.variables. Welcome to the community If you just wanted to log the whole response body to the Postman console, this would be all you need. I already tried with 2 different variables but then i receive both values in the following format Test- 1234. Pm.expect(pm.response.json().id).to.equal(pm.variables.get("id")) ) Hi there I like to have an output of a created variable who is actually using the result of another variable but i do not get the value that i want in the console log. Pm.expect(pm.response.json().name).to.equal("Transformers")) I thought else if give me the expected result. We can use the id variable to do that: pm.test("success status", () => pm.response.to.be.success ) I want get a consol.log when the installment value in my JSON is below 100(when test FAIL).But as result, I have a PASS and FAIL in test results, thats work but I cant get any info in consol.log. Secondly, we know which id to expect this time, so let’s verify that id. Because the tests are similar, we can copy the tests from the POST request, then make a few changes.įirstly, we don’t need to set the id variable again, so let’s not copy that line. Since there’s no body for a GET request, let’s proceed directly to the Tests tab. Variables, when appearing outside of scripts, are referenced using the double-brace syntax. This means you can use the Postman Console to help debug your requests when an API isn't behaving as you expect. ![]() Thus, the GET request should retrieve the same instance that was created by the POST. Getting help Debugging in the console Every request sent by Postman is logged in the console, so you can view the detail of what happened when you sent a request. ![]() In this URL, we’re referencing the id variable that we previously set during the POST request. Because the only thing i can do with this already cleaned data it show it on the console.log.
0 Comments
Leave a Reply. |
AuthorWrite something about yourself. No need to be fancy, just an overview. ArchivesCategories |