Postman has a powerful scripting environment that enables you to add JavaScript code (scripts) in your gRPC requests. You can define scripts for three hooks available during the request execution lifecycle:
You can use scripts to write API tests, debug your requests by logging to Postman Console, or dynamically read/update the values of variables. You can import packages with scripts and tests from your team's Package Library. You can also import packages from external package registries, such as npm and JSR.
Once you invoke your gRPC request, updates to scripts in the On message tab won't take effect until the next time you invoke the request.
The Postman Sandbox is available to you when you write your Before invoke, On message, and After response scripts. The sandbox is a JavaScript execution environment where your scripts run.
To see several example test scripts for gRPC requests, go to Write tests for gRPC requests using JavaScript assertions in Postman.
To learn more about Postman test scripts in general, see Write scripts to test API response data in Postman.
Last modified: 2024/06/12