Recently, I was working on an issue that required me to send hashed information in a query parameter for an endpoint. Instead of hashing the value in an external tool and copying it over to Postman, I used the
pre-request script in combination with the body
form-data to solve this issue. In this post, I will share the script that I used to accomplish this.
Using the Pre-Request Script
pre-request script I added the following script.
hash = CryptoJS.MD5(pm.request.body.formdata.get('source')).toString();
pm.request.addQueryParams('source=' + hash)
This fetches the
source from the
form-data fields and hashes it into an MD5 string. This method may not be the best way, but it works for me and I wanted to share it with others who may be facing a similar issue.
I hope this helps you with your own query parameter hashing needs!