What are Snippets in Postman?

PostmanREST APISOAP API

Snippets are small scripts used in Postman which are used to verify an API. These are pre-developed scripts that can be utilized directly. Thus it helps to save a good amount of time.

Snippets can be used in the Pre-request Script and Tests tabs in Postman. Navigate to the Tests tab and the SNIPPETS section should be available to the extreme right of the screen. Click on any snippet to use it in a script.

On clicking the link Get a variable, the below script gets populated in the Tests tab which can be used in our own script −

pm.variables.get("variable_key");

Navigate to the Pre-Request Script tab and the SNIPPETS section should be available to the extreme right of the screen. Click on any snippet to use it in a script.

On clicking the link Get an environment variable, the below script gets populated in the Pre-request Script tab which can be used in our own script −

pm.environment.get("variable_key");

raja
Published on 25-Jun-2021 16:20:48
Advertisements