guivho
guivho

Reputation: 365

Why does Postman ignore the protocol and port nr in variables?

Postman ignores the protocol and port nr in a variable:

I have a host variable set up to contain a custom port:

enter image description here

When I try to use the variable, it doesn't contain protocol nor port: enter image description here

Do I have to do something special to have the protocol and port nr remembered?

Upvotes: 1

Views: 799

Answers (2)

PDHide
PDHide

Reputation: 19979

The variable you add is in collection while the value is from environment: Read about scope and precedence of variables . Delete environment variable to get value from collection variable. 'E' indicate that value is coming from environment , if no environment then it will show as 'C' meaning collection

https://learning.postman.com/docs/sending-requests/variables/#variable-scopes

enter image description here

In postman precedence is from down to bottom and scope is from top to bottom

Scope:

Meaning if you have global variable defined then it will be visible for all collections and environment variable will be visible only for that particular environment.

Precedence

if you have a variable with same name defined in both environment and collection then the value will be taken from environment. as precedence is collection < environment

Upvotes: 2

Roland
Roland

Reputation: 79

Is there another host variable set ? As that one shows scope Environment in the second screenshot and the first screenshot shows it set at collection scope. Try to rename the host variable for the collection to something else and then try to call it in the same collection and see what it shows. Verification On both the postman Linux and Web client, setting a collection variable called host like yours showed the protocol and port on calls within that collection.

Upvotes: 1

Related Questions