pre-request scripts #3806
-
What about implementing a feature like this one https://learning.postman.com/docs/writing-scripts/pre-request-scripts/ ? |
Beta Was this translation helpful? Give feedback.
Replies: 34 comments 59 replies
-
Could you please provide a use-case for what you'd use this for? What's something you'd like to do today with insomnia that you can't without a feature like this? |
Beta Was this translation helpful? Give feedback.
-
Dammit, here I am begging for this feature hahah. If needs help to develop, I'm not into this code but I'm in. 🤘🏼 |
Beta Was this translation helpful? Give feedback.
-
Hello, |
Beta Was this translation helpful? Give feedback.
-
My use case is to calculate a HMAC value from the body provided, before I send a request and populate a header value with it |
Beta Was this translation helpful? Give feedback.
-
hi chiming in here, my use-case is to insert unwanted characters during api call. thanks. |
Beta Was this translation helpful? Give feedback.
-
Hi, |
Beta Was this translation helpful? Give feedback.
-
sadly I will have to go back to postman without this feature in insomnia, as the postman API collections I import/use , leverage this feature for ading API keys to headers prior to each request as a non developer i jsut dont have the bandwidth to figure out how to hack this together in Insomnia |
Beta Was this translation helpful? Give feedback.
-
I made a solution using some custom plugins to get the same pre and post request handling functionality. I made a video, in portuguese, explaining how to use these features (https://youtu.be/NO8p_4vK1G4?t=591). But a pre and post request area built-in would be ideal. |
Beta Was this translation helpful? Give feedback.
-
This would be such a good feature. In my use-case i need to get an acess token for the route i'm trying to test. |
Beta Was this translation helpful? Give feedback.
-
I have the same use case. In Postman, I was using the pre-request script to cache an auth token in the environment, then populating the Authorization header from that environment variable. Whenever the token expired, the script would automatically retrieve a new one. |
Beta Was this translation helpful? Give feedback.
-
This solves your case : https://docs.insomnia.rest/insomnia/chaining-requests |
Beta Was this translation helpful? Give feedback.
-
In our case, we create a sign with the CryptoJS library with a given string, extracted from some keys of the body. It seems that sign can be only made on the go when you make the post request. |
Beta Was this translation helpful? Give feedback.
-
In my case, I need to send JSON message and some attachments in one POST request by multipart-data/form option. But in case option is multipart-data/form, Insomnia will set JSON part as string and send to server, so that I have to decode this part. So that if has pre-request scripts or option to combine STRUCTURED/Multipart Form and TEXT/JSON is very comfortable. |
Beta Was this translation helpful? Give feedback.
-
Hi! Any news on this? I actually want to migrate from Postman, but I used pre-request scripts to generate headers for requests to AWS. |
Beta Was this translation helpful? Give feedback.
-
I would also be very interested to have this feature. My usecase is: |
Beta Was this translation helpful? Give feedback.
-
To be honest, this was the reason why we switched to postman. No need for workarounds or custom solutions. It's just there and working. |
Beta Was this translation helpful? Give feedback.
-
The most challenging part will be not creating a plugin with input for JS and even not about how to run it before request. But what should this script be for? Changing of variables in request? Replace/Inject body? Build/Update the request URL? I think the most difficult part will be to add access for a script to Insomnia world, as Insomnia provided very limited access to application variables/methods even for plugins |
Beta Was this translation helpful? Give feedback.
-
The pre-request feature is a critical functionality that we would require in As a result, we are actively searching for an alternative tool, and |
Beta Was this translation helpful? Give feedback.
-
Update: we are currently allocating resources to work on this issue, we will post more updates once we have a better idea on the timeline. |
Beta Was this translation helpful? Give feedback.
-
Beta Was this translation helpful? Give feedback.
-
Here is a preview video of pre-request scripting that we are building: 📹 https://www.loom.com/share/9e6f1253f8ca48bca49788f94fde8063 You can see how to:
We want to ship a preview of this capability ideally this month. |
Beta Was this translation helpful? Give feedback.
-
The beta release with pre-request scripting is out! You can download it at https://github.com/Kong/insomnia/releases/tag/core%409.0.0-beta.1 With this new release you will see a new "Pre-request Script" tab in the collection view, where you can create scripts:
|
Beta Was this translation helpful? Give feedback.
-
A new beta version has been released with notable improvements to the pre-request scripting capability: https://github.com/Kong/insomnia/releases/tag/core%409.0.0-beta.3 We have another couple of known improvements that we want to make, before releasing it as GA in the next few weeks. |
Beta Was this translation helpful? Give feedback.
-
Habemus pre-request scripting! The new version of Insomnia 9.0 has been shipped with pre-request scripting available in the collections among many other features. We will now work towards enabling post-request scripting which should ship in approximately one month, in the meantime let us know if there are any improvements you would like to see in pre-request scripting and we will address them in the next releases. Known gaps that will be solved shortly in the next releases are:
I will close this discussion for now. |
Beta Was this translation helpful? Give feedback.
-
Awesome ! Will it be possible to use some sort of basic require/import to at least have some default libs built-in ? I tried using Crypto with the same exact use case as the one that started this thread, couldn't import it or use it. Postman provides the deprecated CryptoJS by default I think. However having the latest standard one would be best I guess. |
Beta Was this translation helpful? Give feedback.
-
Hi, my use-case - generating 1 time token from a const secret. this token is required for each api (i have about 30) |
Beta Was this translation helpful? Give feedback.
-
I wanted to let you know that we have also completed the beta for post-request scripting (or after response scripting). More info at #6242 (comment) |
Beta Was this translation helpful? Give feedback.
Habemus pre-request scripting!
The new version of Insomnia 9.0 has been shipped with pre-request scripting available in the collections among many other features.
We will now work towards enabling post-request scripting which should ship in approximately one month, in the meantime let us know if there are any improvements you would like to see in pre-request scripting and we will address them in the next releases.
Known gaps that will be solved shortly in the next releases are:
globals
environment variables SDK is not supported because we need to introduce first the concept of global environment variables in the product, which we also will ship shortly.