postmanlabs / postman-app-support

Postman is an API platform for building and using APIs. Postman simplifies each step of the API lifecycle and streamlines collaboration so you can create better APIs—faster.
https://www.postman.com
5.8k stars 839 forks source link

Add postman to code snippet languages list #12806

Open albaquarto opened 3 months ago

albaquarto commented 3 months ago

Is there an existing request for this feature?

Is your feature request related to a problem?

Should be usefull using code snippet for generate requests script with also correct functions for get/set variables.

Describe the solution you'd like

1)Add postman to code snippet languages list and create a complete snippet with postman functions (also variables get/set)

2) Send a request in the script by link or id or id, but if I need some different variables I have to create a new request for every variation.

Describe alternatives you've considered

1) I use nodejs Axsios code snippet and replace the final values and the axios call with correct functions call. but is really annoyng and slow.

Additional context

Example:

I have a request like this Screenshot from 2024-04-22 11-04-21

Screenshot from 2024-04-22 11-04-40

base-url, user-username and user-password are environment variables in the test I use the result to set the environment variable access-token

I need to use the login before a set of other requests to obtain token to use in that requestes. So I use the pre request script The pre-request script that do exactly the same thing of the preview request is this Screenshot from 2024-04-22 11-20-48

I had to write manually the pre request or I could use the code snippet tath prouce the code below and modify it to take the values from the variables. Screenshot from 2024-04-22 11-33-55

This is a simple example but more complex situations may exist. This is why I believe that a feature like a postamn code snippet producer could be useful to produce the expected result (what I wrote in the third image) more quickly and easily.

CommanderStorm commented 3 months ago

I think I am missing something here. What do you mean by "correct functions for get/set variables"?

For me the variables set in the variables tab are corectly templated into the script. Could you provide a screenshot of what clarifying this?

albaquarto commented 3 months ago

I think I am missing something here. What do you mean by "correct functions for get/set variables"?

For me the variables set in the variables tab are corectly templated into the script. Could you provide a screenshot of what clarifying this?

Sorry, I didn't explain well. I provided an example.