0% found this document useful (0 votes)
16 views

Postman: Are Places To Organize Your API Requests in Postman

Uploaded by

onlineganesh87
Copyright
© © All Rights Reserved
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
16 views

Postman: Are Places To Organize Your API Requests in Postman

Uploaded by

onlineganesh87
Copyright
© © All Rights Reserved
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
You are on page 1/ 3

APIs are mechanisms that enable 2 software components to communicate with each other using a

set of definitions and protocols.

A contract that allows a code to talk to other code

Types of API

Hardware – phone camera talking with os

Software – using methods from a library into ur application

Web-fetching current stock prices from a financeapi over the internet.

Example: uploading an image to instagram

1. Hardware api for the app to talk to ur camera


2. Software library api for the image to be processed with filters
3. Web api for sending ur image to instagram’s servers so ur frnds can like it.

REST(Representational State Transfer)

Some traits of REST APIs include not storing session state between requests, the ability to cache, and
the ability to send and receive various data types.

Depending on access there are 3 types

Public, private, partner

Postman is an API platform for building and using APIs. Postman simplifies each step of the API
lifecycle and streamlines collaboration so you can create better APIs faster and consume them with
ease.

Collections are places to organize your API requests in Postman.

CRUD – create, Read, Update, Delete

GET – Read

POST – Create

PUT/PATCH – Update put replaces an entire resource whereas patch usually is for partial updates

DELETE – Delete
Code range Meaning Example

200 - OK
2xx Success 201 - Created
204 - No content (silent OK)

301 - Moved (path changed)


3xx Redirection

400 - Bad request


401 - Unauthorized
4xx Client error
403 - Not Permitted
404 - Not Found

500 - Internal server error


5xx Server error 502 - Bad gateway
504 - Gateway timeout

the minimum ingredients you need to make a request are:

 a request method (GET/POST/PUT/PATCH/DELETE, etc)

 a request URL

Query parameter syntax


Query parameters are added to the end of the path. They start with a question mark ?,
followed by the key-value pairs in the format: <key>=<value>. For example, this
request might fetch all photos that have landscape orientation:

GET https://some-api.com/photos?orientation=landscape

If there are multiple query parameters, each is separated by an ampersand &.

Scripting in Postman
Postman allows you to add automation and dynamic behaviors to your collections
with scripting.
Postman will automatically execute any provided scripts during two events in the
request flow:

1. Immediately before a request is sent: pre-request script (Pre-


request Script of Scripts tab).

2. Immediately after a response comes back: post-response


script (Post-response of Scripts tab).

The pm object
Postman has a helper object named pm that gives you access to data about your
Postman environment, requests, responses, variables and testing utilities.

For example, you can access the JSON response body from an API with:

pm.response.json()

You can also programmatically get collection variables like the value of baseUrl with:

pm.collectionVariables.get(“baseUrl”)

In addition to getting variables, you can also set them


with pm.collectionVariables.set("variableName", "variableValue") like this:

pm.collectionVariables.set(“myVar”, “foo”)

You might also like