request parameters code example

Example 1: variable types in api

1-GLOBAL variables allow you to access data
between collections, requests, test scripts,
and environments. Global variables are
available throughout a workspace.

2-COLLECTION Only accessible within the same collection and
can not be accessed anywhere else
COLLECTION variables are available throughout 
the requests in a collection and are independent
of environments, so do not change based on the selected environment.
I use collection variables when
I use single environment like url details.
We can refer to the variable by using {{}}(double curly brace)
and  it can be used anywhere

3-ENVIRONMENT Variable , a variable that accessible
only when the environment is active 

Usually used for an app with multiple environment ,
we can use env variable to store variable with same name
and different value to store environment specific data 

for example : 

xxxNamed app has 3 environments with different
URL and Crendentials 

But all endpoints are exactly the same no matter what
environment you work on 

so we can create 3 environment called 
QA1 , QA2 , QA3 and run same set of request 
by selecting different environment.

Only one environment can be active at a time.

4-LOCAL variables are temporary, and only
accessible in your request scripts. 
Local variable values are scoped to a 
single request or collection run, and are no longer
available when the run is complete.


5-DATA variables come from external CSV and JSON files
to define data sets you can use when running collections
via the Collection Runner.

Example 2: types of parameters in rest service

2 TYPES OF PARAMETERS IN REST SERVICES:

1) QUERY PARAMETERS:
-> is NOT part of url and passed in key=value format
those parameters must be defined by API developer
http://34.223.219.142:1212/ords/hr/employees?limit=100
Query parameters are the most common type of parameters. 
They appear at the end of the request URL after a question mark (?), 
with different name=value pairs separated by ampersands (&). 
Query parameters can be required and optional.
GET /pets/findByStatus?status=available
GET /notes?offset=100&limit=50

2) PATH PARAMETERS
Path parameters are variable parts of a URI path. They are typically 
used to point to a specific resource within a collection, such as a user
identified by ID. A URL can have several path parameters, each 
denoted with curly braces { }.
GET /users/{id}
GET /cars/{carId}/drivers/{driverId}
GET /report.{format}

Tags:

Misc Example