What should i do if the endpoints which require bearer token (protected routes) - are giving bad token or token expired response ?
In this case, you need to make sure to call the login endpoint with correct credentials again as payload in the body and use the newly generated token or You can create a new registration and login, then use the newly generated token for the protected routes
How to validate the response that we are getting from the server ?
You need to use assert statements and check out how to use JSONObject and JsonPath.
JSONObject - We use this to make key and value pairs for the payload.
JsonPath - We use rest-assured JsonPath to look up for values based on the Object path expression.
For Encoding and Decoding of JSON Text in java:
https://mvnrepository.com/artifact/org.json/json/20171018
http://stleary.github.io/JSON-java/index.html
JSONPath:
https://www.javadoc.io/doc/io.rest-assured/json-path/latest/io/restassured/path/json/JsonPath.html
How to add global environment variables in postman ?
To view global variables, do the following:
Select Environments in the sidebar.
Select Globals.
To add a new global variable, do the following:
Select Add a new variable, and enter a name for the variable.
Select a Type for the new variable.
Add an Initial Value, and if you choose, a Current Value.
Select Save icon Save to confirm your changes
How to resolve 404 and 502 status code error while writing API Testing code ?
Make sure the endpoint is correct and also check your code whether you are setting content Type header value as application/json
Eg:
How to use saved global / collection based variables in postman ?
You can use double curly braces to reference variables throughout Postman. For example, to reference a variable named "username" in your request authorization settings, you would use the following syntax with double curly braces around the name:
For example, you could have a request URL referencing a variable as follows:
https://postman-echo.com/get?customer_id={{cust_id}}
Note how we are using the variables that we have defined in our url as well as in the json body payload
Here the variable names our:
base_root_url - base root url string
pms_email - email string
password - password string
Was this article helpful?
That’s Great!
Thank you for your feedback
Sorry! We couldn't be helpful
Thank you for your feedback
Feedback sent
We appreciate your effort and will try to fix the article