Request dynamic parameters (e.g. timestamps)
Sometimes when we request an interface, we need to bring the current timestamp of such dynamic parameters, so can postman automatically fill in.
We can use postman's pre-request script
First, we fill in the request parameters with the value parameter {{var}} in this manner
Then add the js code in the pre-request script as follows. Where var is the same name defined in the previous step, you can modify it according to your needs.
('var',(new Date()/1000)+10);
After adding the following figure.
View the backend request log, where the parameter value changes to a timestamp in seconds
Request the appropriate test
If you want to process the data returned from a request and test it for validation, you can use a test script by clicking on Bootcamp under postman, and the following menu will appear, which provides several tutorials on how to use it, including the pre-request script described above.
Click Automated testing, click learning in the secondary menu Working on test scripts and follow the tutorial step by step.
This is all you need to know about postman to pass the current timestamp, thanks for learning and supporting me.