If we were to do this without pre request script we will have to run this algorithm, use the output as header and make the call. This hmacToken is generated via signing a string containing your token and timestamp with a secret. We have to make a POST API call to which will only succeed if the request contains a header hmacToken. its value will change with every API request. There are APIs which require you to have a param (or header) which is generated in real time, i.e. Lets look at both of the cases with a detailed example. Postman allows you to write a pre request script which will run before the actual API call and do the all the things which were doing manually. If you are lazy like me this seems too much trouble, especially when your params have expiry and you have limited time window to do those operation manually.Įnter pre request scripts. For third you will make the first API call, copy response and use those as params in next API call. For second you will have to run a script to generate those real time params and then manually enter them in postman. While the first use case is fairly simple to test on postman, second and third cases are tricky. they make an API call and use the response of this API call as the params of next API call. Third is when your clients chain requests i.e. These can be a things like generating a signature containing timestamps so they will be different every time. Second use case is when the params themselves are computed on clients and then sent to servers. In real world scenarios there are three ways we handle params and process them further.įirst is when the params are just user inputs and you can plainly use for further processing like fetching from DB. Although we might be familiar with making basic http requests with postman, it gives us a lot more power in terms of programming things around an API request. Postman has become the default option to make and test API requests.
0 Comments
Leave a Reply. |
AuthorWrite something about yourself. No need to be fancy, just an overview. ArchivesCategories |