Postman using environments to parameterize data.
When testing we need to test API with multiple environments and several parameters.
I want to test register successful post request in base url -https://reqres.in/
end point is /api/register
For that we can use environment feature in Postman.
First of all add an environment by clicking New.
Then create New.
Then add values to the environment.
When adding urls and end points make sure not to add / sign at the end if you are giving url as {{home}}/{{Api_register_end_point}} after parameterize.
otherwise, there will be // and request won’t work.
https://reqres.in/api/register
Before parametrization the request is looks like below.
URI is https://reqres.in/api/register
Note- make sure to add
Content-Type =application/json
Payload Body is as per below.
{
“email”: “eve.holt@reqres.in”,
“password”: “pistol”
}
To parameterize , use {{varable_name}} also check that environment is selected from the dropdown.
So URI is
{{home}}/{{Api_register_end_point}}
By hover over it , can see the values.
Payload is
{"email": "{{email}}","password": "{{password}}"}
When it ran below response should come.