App Details:
Postman for Chrome
Version 5.0.1
win / x86-64
Chrome 58.0.3029.110
In my collection, I have various requests within folders.
e.g. Collection>CollectionFolder1>Request1, Request2 ...
Is it possible to get a reference of the request names within the tests so that I could write something like:
try {
...
} catch (e) {
tests[Test failed with exception ${e} for call request ${SOME_VARIABLE_THAT_STORES_REQUEST_NAME}] = false
}
This would allow me to duplicate this skeleton in all my requests without having to bother about maintaining it.
Is there any postman variable or structure that would store any such info.
If you mouse over the name of the request below the tab a pencil edit icon should appear, click it and then edit the name. Or within your collection on the left hand side of the app you can mouse over the name of the request, click on the ellipsis and then select Rename.
The Body tab in Postman allows you to specify the data you need to send with a request. You can send various different types of body data to suit your API. If you're sending body data, make sure you have the correct headers selected to indicate the content type your API may need to process the received data correctly.
You can write test scripts for your Postman API requests in JavaScript. You can also use test code to aid the debugging process when something goes wrong with your API project.
In https://www.getpostman.com/docs/postman/scripts/postman_sandbox - paragraph Request/response related properties you can use the 'request' object.
Obsolete use request.name
: gives you the current test case namepm.info.requestName
request.method
: gives you the method used (PUT, GET, etc.)
request.url
: gives you the target url
In order to see all the available data you may use, I suggest you to open the console (View/Show postman console or Alt+Ctrl+C) and see the data returned by this:
console.log(request)
Postman v6.5.2 and up uses pm.info.requestName
console.log("Running: "+ pm.info.requestName);
Look at pm.info
object:
https://learning.postman.com/docs/writing-scripts/script-references/postman-sandbox-api-reference/#scripting-with-request-info
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With