0
0
Postmantesting~5 mins

REST API fundamentals review in Postman

Choose your learning style9 modes available
Introduction

REST APIs let different software talk to each other over the internet. Testing them ensures they work correctly and return the right data.

When you want to check if a website or app can get data from a server.
When you need to verify that sending data to a server saves it properly.
When you want to make sure deleting or updating data works as expected.
When you want to test how the server responds to wrong or missing information.
When you want to automate checking your API regularly to catch problems early.
Syntax
Postman
METHOD URL
Headers: key: value
Body: (optional, for POST/PUT/PATCH)

METHOD is the HTTP method like GET, POST, PUT, DELETE, PATCH.

URL is the web address of the API endpoint.

Examples
Fetch a list of users with authorization.
Postman
GET https://api.example.com/users
Headers:
  Authorization: Bearer your_token_here
Create a new user by sending JSON data.
Postman
POST https://api.example.com/users
Headers:
  Content-Type: application/json
Body:
  {"name": "Alice", "email": "alice@example.com"}
Update the email of user with ID 123.
Postman
PUT https://api.example.com/users/123
Headers:
  Content-Type: application/json
Body:
  {"email": "newemail@example.com"}
Delete the user with ID 123 using authorization.
Postman
DELETE https://api.example.com/users/123
Headers:
  Authorization: Bearer your_token_here
Sample Program

This request fetches the post with ID 1 from a public test API. It expects JSON data back.

Postman
GET https://jsonplaceholder.typicode.com/posts/1
Headers:
  Accept: application/json
OutputSuccess
Important Notes

Always set the correct Content-Type header when sending data.

Use authorization headers if the API requires login or tokens.

Check the response status code to know if the request succeeded (e.g., 200 OK, 201 Created).

Summary

REST APIs use HTTP methods to perform actions on data.

Testing REST APIs means sending requests and checking responses.

Postman is a tool that helps you send these requests easily.