DEV Community

Cover image for Postman Testing
SAKSHI
SAKSHI

Posted on

Postman Testing

Have you ever created a Github repository via Git? Many times, I guess. But have you created a repo via calling HTTP APIs.
Let's Know about APIs & a Testing platform i.e. Postman.

What is POSTMAN?

Postman is a Google Chrome app for interacting with HTTP APIs. It presents you with a friendly GUI for constructing requests and reading responses. It works on the backend and makes sure that each API is working as intended.

It is an API client.
Develop, Test(Manual & Automated), Share & Document APIs.

Postman is the way to streamline the process of API testing.
Download Postman for your OS: https://www.postman.com/downloads/

https://miro.medium.com/max/1200/1*tO_SemO2SWDsmN1bzIwmcA.png

What we will do?

We will create a repository via POSTMAN with Github API. We will create a Github Access token, use that token to manage our Github Account, and then Postman will send a request to github.com to make a new repository on the specified account to which the token belongs to & hurray we'll get a response with Status: 201 Created.

Resources/References:

Postman on Youtube: https://www.youtube.com/channel/UCocudCGVb3MmhWQ1aoIgUQw

πŸ“˜ Read about Github APIs: https://docs.github.com/en/free-pro-team@latest/rest

πŸ“˜ Read about Repositories API version3: https://developer.github.com/v3/

πŸ“˜ Read about Repositories API version3 (current version): https://developer.github.com/v3/#current-version

Let's start with POSTMAN using Github API. Below are some instructions, follow & you are good to go then.

Starting with POSTMAN + Github API

  • Step1:
    -> Make an Account on Github
    -> Go to Settings (find it in the dropdown located at top left corner)
    -> Go to Developer Settings (left panel)
    -> Click on Personal Access Tokens
    -> Click Generate New Token copy & save it. (It's a private key, Don't share it with anyone)🀫

  • Step 2:
    -> Download & Install Postman. Log in with Google or anything you want and Open it.

    • Create a Workspace
    • Create a Request
    • Go to Environment Variable on the top-right corner & click on settings(Manage Environment)

      • Add / Creare an environment
      • Name the environment: Github API
      variable Initial Current
      token Leave it empty Paste Your github access token here
      • Update
    • Choose the environment

    • Create a new request

    • Environment Setup is done.

  • Step3: Now, Make a Request.

    POSTπŸ”½ https://api.github.com/user/repos
    POST means we are creating a new repo. POST /user/repos
    POST sends new data to an API Creates a new repository for the authenticated user.

You can make requests to APIs in Postman. An API request allows you to retrieve data from a data source, or to send data. APIs run on web servers and expose endpoints to support the operations client applications use to provide their functionality.
Each API request uses an HTTP method. The most common methods are GET, POST, PATCH, PUT, and DELETE.
- GET methods retrieve data from an API.
- POST sends new data to an API.
- PATCH and PUT methods update existing data.
- DELETE removes existing data.

PUT means to change/update/modify something in existing data on the server and POST means to add new data to the server



  • Choose Body
  • Select raw & JSON & paste this example data. Change the repository name and description as per your choice. This Repo will be Public as private = false
{
  "name": "Hello-World",
  "description": "This is your first repository",
  "homepage": "https://github.com",
  "private": false,
  "has_issues": true,
  "has_projects": true,
  "has_wiki": true
}
Enter fullscreen mode Exit fullscreen mode
  • Click Send
  • Status: Error 401 Authorization Error(Unauthorised)
  • To Enable Authorization: Go to Authorization -> Type -> Bearer Token (As we have token)-> Put the token as {{token}} (safe way to use token)
  • Send
  • Status: OK 201 Created

🎊✨ A repository has been created on your GitHub accountπŸ–₯: https://github.com/Sakshi-25/PostmanTesting

Join My Postman Team :
https://app.getpostman.com/join-team?invite_code=6fca5c1182d659f6faa3987a216a6c97&ws=8061b583-de7c-48be-b5d4-e2af5f9a6c02

Top comments (0)