Postman Rest API


Rest API

REST stands for Representation State Transfer.

REST APIs operate on a simple REQUEST/RESPONSE system.

Client can make a request using HTTP Methods.

Server returns a response with an HTTP status code.

HTTP Request contains

• Request method

• HTTP Headers

• Body

HTTP Response contains

• Status Code

• HTTP Headers

• Response Body

What is Postman REST API?

Building, testing, and modifying APIs are made easier with Postman, an API development platform. Every stage of the API lifecycle is made simpler, and cooperation is made more efficient, enabling you to produce better APIs.

How to use Postman to execute APIs?

Here is a full overview of all the Postman REST API's features and operations. Below is a screenshot of a Postman Workspace.

1. New – New requests, collections, or environments can be made with this.

2. Import – With this, you can import a collection or an environment. Additionally, you can import from a file, folder, link, or paste the raw text.

3. HTTP Request – GET, POST, PUT, DELETE, and more HTTP requests are available in this option.

4. Invite – Team members are invited to collaborate in the workspace using this.

5. Save – As soon as new modifications are made, you must save them all. Otherwise, they will be overwritten or lost.

6. Request URL – Another word for this is an endpoint. You may determine the connection to your API's communication using this.

7. Params – All of a request's necessary parameters, such as key values, must be entered.

8. Authorization – Safe access necessitates authorization, which might take the form of a bearer token, username and password, etc.

9. Headers – Based on your organization’s requirement, you can choose headers such as content type JSON.

10. Pre-request Script – These scripts are employed to check whether the test is being executed in the appropriate environment. This is carried out before the request itself.

11. Body – The request information can be modified here.

12. Tests – These scripts must be run during the request. All of them serve as checkpoints to confirm the state of the answer, the data obtained, and other testing.

13. My Workspace – With this, you can create a new workspace individually or as a team.

14. Collections – This is used to organize all your test suite using collections.

Call REST APIs Using POSTMAN Client:

In POSTMAN we got many methods but we use only GET, PUT, POST and DELETE

• POST – This Call creates a new entity.

• GET – This call sends the request and receives the response.

• PUT – This call creates a new entity and updates the existing entity.

• DELETE – This call deletes the existing entity.

• PATCH – This method is used to modify the resource on the server

• COPY – This method creates duplicate of the source resource identified by the Request-URI.

• HEAD – Same as GET, but transfers the status line and header section only.

• OPTIONS – This method fetches the list of supported options of resources available on the server.

HTTP RESPONSE STATUS CODE:

200 Ok – Everything is fine

201 Created – New Resource was created

301 - Moved permanently the resource has been moved permanently to the new URL.

Client Error:

400 Bad request – invalid syntax

401 Unauthorized – Credentials are incorrect

403 Forbidden – You don’t have permission to access the resources.

404 Not found – Invalid URL.

429 Too many requests – User has sent too many requests in a given amount of time.

Server Error:

500 Internal server error – Server does not know how to handle the unexpected situation.

REQUEST TIME:

When analysing Request time, it will further break it down into its component parts, such as Connect time, Socket time, DNS lookup, Handshake, etc.

RESPONSE SIZE:

The same is true for response size, which will display a breakdown of the size of the headers and the actual response size.

Implementing GET Requests:

Working Environment:

1. Set GET as the HTTP request type.

2. Enter link in the request URL area

https://jsonplaceholder.typicode.com/users

3. Select "Send"

4. You'll notice a 200 OK Message.

5. The body of your test should contain 10 user results, which is a sign that it was successful.

Implementing POST Requests:

Working Environment:

1. Set POST as the HTTP request type.

2. Specify the same URL in the request field:

https://jsonplaceholder.typicode.com/users

3. Go to Body – > Select RAW > pass JSON and select JSON from the dropdown

4. Just one user result from the prior get request should be copied and pasted as shown below. Check to see that the curly braces and brackets have been copied appropriately. Change the name to any preferred name and the ID to 11. You can alter other information as well, such as the address.

Code Snippet

5. Next, Click Send.

6. Status: 201 Created should appear.

7. Posted data are showing up in the body.

Implementing PUT Requests:

Working Environment:

1. Set PUT as the HTTP request type.

2. Specify the URL in the request field:

https://reqres.in/api/users/2

3. Go to Body – > Select RAW > pass JSON and select JSON from the dropdown

4. And paste the payload script.

{

"name": "Meghana",

job": "Associate software"

}

5. Press the SEND button, for a successful request.

6. You will get the Status 200 – Ok, the response is received successfully.

7. Updated data are showing up in the body.

Implementing DELETE Requests:

Working Environment:

1. Set DELETE as the HTTP request type.

2. Specify the URL in the request field:

https://reqres.in/api/users/423

3. Payload not required. Press the SEND button.

4. Deletes user id =423 if available in the system.

5. Status 204 – No Content, the response received successfully.

6. No Payload received, user id deleted.

CONCLUSION:

An API testing tool called Postman is available for free. Before releasing the product, APIs must be tested because they are utilised for software interaction. The development code's continuous integration is supported.

Get in Touch and let us know
how we can help

Get started

Our brand name and motto embody our unwavering commitment to delivering services with agility, quality, and efficiency, ensuring that our clients and international business partners receive unmatched excellence.

Address

meteoriQs Towers,
1B, Ground Floor Business Center,
SheshadhriNagar,
Nedungundram,
New Perungalathur,
Chennai-127, India