Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to get Postman Environment and Postman Globals URLs for passing to Newman?

Tags:

postman

newman

Newman help specifies that collection, environment and globals can be passed as a path or as a URL. I can see how to get a collection URL from Postman (by going to Share > Collection Link).
How can I get the URLs to Environment and Globals in Postman, so I could pass them to newman?

like image 246
YuriK Avatar asked Sep 28 '17 03:09

YuriK


People also ask

How do I find my Postman environment URL?

On the Collection list page, you will see Environments as a tab next to Collections. Select the Environments tab, then select the specific environment you want. The URL on this page is the Environment's URL you can use for Postman.

How do I pass an environment variable in Newman?

Allows you to set environment variables in a key=value format on the command line. You can add multiple environment variables using --env-var multiple times, for example: --env-var "key1=value1" --env-var "key2=value2" .

How do I add an environment URL to my Postman?

In the top right corner of Postman, click the environment selector and select Manage environments. Click Add to add a new environment where you'll define your OneLogin environment variables. Note: You'll need to use your API credentials to generate the access_token value.


Video Answer


2 Answers

Using Newman with the Postman Pro API:

  1. Generate an API key
  2. Fetch a list of your collections from:
    https://api.getpostman.com/collections?apikey=$apiKey
    
  3. Get the collection link via its UID:
    https://api.getpostman.com/collections/$uid?apikey=$apiKey
    
  4. Obtain the environment URI from:
    https://api.getpostman.com/environments?apikey=$apiKey
    
  5. Using the collection and environment URIs acquired in steps 3 and 4, run the collection as follows:
    newman run "https://api.getpostman.com/collections/$uid?apikey=$apiKey" \
        --environment "https://api.getpostman.com/environments/$uid?apikey=$apiKey"
    

Link to Newman package

like image 125
testmonger Avatar answered Oct 19 '22 18:10

testmonger


Using the Postman desktop app please try the following steps -

  1. View your collection in Postman
  2. From the collection details view (press the arrow next to the collection name) and select View in Web.
  3. In the Postman web view, next to the Postman logo on the right, there is a drop-down.
  4. From the drop-down select the Workspace where your test collection is in.
  5. On the Collection list page, you will see Environments as a tab next to Collections.
  6. Select the Environments tab, then select the specific environment you want.
  7. The URL on this page is the Environment's URL you can use for Postman.
like image 2
Peter Avatar answered Oct 19 '22 18:10

Peter