(solved) Creating request for login

Hi all -

Just getting started with Postman (impressed so far). I’ve inherited a collection file from someone. Among others, it has this entry:

			"name": "Log In",
			"request": {
				"method": "POST",
				"header": [
					{
						"key": "Content-Type",
						"value": "application/json",
						"type": "text"
					}
				],
				"body": {
					"mode": "raw",
					"raw": "{\n\t\"email\": \"mzimmers@fluidra.com\",\n\t\"password\": \"mypassword\"\n}"
				},
				"url": {
					"raw": "https://{{environment}}.zodiac-io.com/users/v1/login",
					"protocol": "https",
					"host": [
						"{{environment}}",
						"zodiac-io",
						"com"
					],
					"path": [
						"users",
						"v1",
						"login"
					]
				}
			},
			"response": []
		}

I’d like to get my password out of this file and put it in a variable. This entry is using the “body” for entering these values; can I somehow use variables here?

Thanks…

Hi @mpzimmers

Welcome to the postman community.

Yes, that is very simple to do. If you had not noticed your example is already using variables for the environment. e.g. {{environment}}.

You can do a similar thing with the password. Create an environment variable called ‘password’ for example. Then add your password as the current value as opposed to the initial value, also you can make the type secret so that it is not visible when you open the environment variable panel.

Like this:

Hope this helps.
Cheers.

Hi Paul - thanks for the help. (I thought I’d tried that, but I guess not.) Your suggestion worked just fine.

Thanks again!

1 Like