I use Postman on a daily basis, and I need a 'token' that changes every 5 minutes. There is no way to get the token using PostMan.
I use an enviroment variable but this means that I have to change this variable every 5 minutes. This means multiple proceedings every time.
Is there a way to save the variable in a file? So I can set variables with my favorite text editor?
Related
So here is my case, I am trying to implement concurrency test using jMeter with over 100 users. I got the foundation set up. However, the challenge I am encountering is that I have two APIs on postman one which I need to get accident case as UIID that is the first API and the second API is an API in which I register the accident. Each accident api requires different accident case. In other words, all 100 users will have different accident case. I usually do that manually when manual test but how do I do that automated in jMeter
enter image description here
Thank you and best regards
You can use __UUID
"accidentCase": "${__UUID()}",
The UUID function returns a pseudo random type 4 Universally Unique IDentifier (UUID).
If you're getting an accident case in 1st request and need to use it in 2nd request you can extract it from the 1st request response using a suitable JMeter Post-Processor and save it into a JMeter Variable
Then in 2nd request you need to replace the 21d2a592-f883-45f7-a1c4-9f55413f01b9 with the JMeter Variable holding the UUID from the first request.
The process is known as correlation and there is a lot of information on it in the Internet.
Using Postman data files for the first time - I have a couple of setup requests / tests to carry out (authentication, clear cache etc.) just once before a data file gets executed against my functional requests.
Do the setup requests need to be in a separate collection to avoid them being executed against every row of my data file, or can I combine them in the same collection somehow while ensuring (a) they are only run once and (b) they are run before the data file is executed?
We also want to execute this via Newman for our nightly automated run.
I would put all requests in one collection.
The very first script being the setup script.
Then in the pre-request script of the setup, you can check pm.info.iteration:Number to get the number of the current iteration and if it's not the first one, use pm.setNextRequest("2nd request") to call the 2nd request in the collection.
Is there a way to reference other collections from a specific collection. For example, if I have a file upload collection (something that uploads a file), I want to be able to use that from other collections. How would I reference the file upload?
Here's an example of what I'm talking about.
I have a collection where a file is uploaded and a calculation needs to be performed. The test or collection would go something like this where each step is a POST, GET, etc
Upload and run calculation:
Generate a token
make call
copy/save token value
Upload specific file (these would be 3 individual requests)
Upload file
Monitor upload status
Return ID of file uploaded
run calculation
use ID to pass as parameter
pass other values to set up calculation
monitor run
validate results
In another collection I need to validate uploaded files metadata is correct. Not directly related to the one above, but has some similarities
Generate a token
make call
copy/save token value
Upload specific file (these would be 3 individual requests)
Upload file
Monitor upload status
Get final result and return ID of file uploaded
Get me
validate metadata is correct.
Steps 1 and 2 are common functionality, there would be no difference there. How could I extract those two steps as modular components or functionality so I can reference them from any collection?
For additional clarity, we use ReadyAPI and are able to do 'Run Test Case' which can obviously run another test case. We've separated the functionality of token and file uploads into it's own test case and use it as a modular component. I'd like to achieve something similar with Postman.
Unfortunately Postman collections are working a little bit different.
But you can Merge your two collections to a single one, and execute it as one single collections.
Postman has been an amazing tool for me, but I have some questions about using variables. In my collection I have 4 tabs/requests.
The first is to get a token that is used in the other three (the token expires after 15 minutes so I have to rerun that request frequently and update the other 3). It needs to be passed in the headers of the other three requests. I'm familiar with the {{variable}} syntax, but I'm not sure how to dynamically set the variable after running the first request.
The second is similar, where I'd like to be able to set a string manually in some central location and use it in all of the requests. For instance, the URL is https://the.api.com/v1/{{someidvalue}}/abc so where can I change that in a single location manually to be reused across the collection?
Thank you!
To change the value based on server response you can use the test feature Postman test script
For exemple
var jsonData = JSON.parse(responseBody);
postman.setEnvironmentVariable("Authorization","Bearer " + jsonData.result.accessToken);
The central location that you are looking for is the enviroment postman manage environments
I have a case where i have a folder in a collection which has to run for a specific set of iterations before going to the next folder.
There is no direct feature in postman yet which allows you to set different iterations at each folder level and still run the collection as whole.
I want to run a specific request in a folder with all the testdata i provide in a json and then move to the next request as per the collection folders.
I tried achieving the same using setNextRequest in the same request which has to be run multiple times but with different data.
However, it runs the same data again for the second time as well and through the runner it goes to iteration 2 which was set to 2 at collection level as well.
How can I achieve my usecase.