Postman

Postman Documentation
Basic of Postman and Newman
Newman

Request

Query Params

?KEY=VALUE

Path Variables

:userid

Scripts and tests

Basic test structure

pm.test("Status code is 200", function () { pm.response.to.have.status(200); });

Response assertions

pm.response.to.have.status(200);

pm.expect(pm.response.responseTime).to.be.below(200);

pm.response.to.have.header(”X-Cache");

pm.response.to.have.header(”X-Cache", “HIT”);

pm.expect(pm.cookies.has("sessionId")).to.be.true;

pm.expect(pm.cookies.get("sessionId")).to.equal("abcb9s");

pm.response.to.have.body( "OK");

pm.expect(pm.response.text()).to.include("Order placed.");

Variables

pm.globals.set("varName", "VALUE");

pm.globals.get("varName");

pm.globals.unset("varName");

pm.globals.clear();

pm.environment.set("varName", "VALUE");

pm.environment.get("varName");

pm.environment.unset("varName");

pm.environment.clear()

pm.variables.get("varName")

Learn Postman by Trello API

Start with trello API
REST API lists

Postman Trello API requests and tests:

  1. Create a trello board

  2. Create two lists TODO and DONE

  3. Create a new card inside TODO

  4. Move the card to DONE

  5. Delete the board

Collection of API Trello
Export Results from Collection Runner

Variables

{{ENVIRONMENT_VARIABLES}} -> Use to easy switch environment. Allways is used before Global Variables

{{GLOBAL_VARIABLES}} -> The same like Environment but it's not easy to switch. And Environment variables has bigger priority.

Debugging tests

console.log(response.prefs);

and click Console to see it.

GitHub API

It could be out of date
Documentation of GitHub API

GitHub Repository

GET https://api.github.com/user/repos

1. Authorization > Type - Basic Auth > Username/Password to GitHub 2. Send Request

Path Parameters

Name
Type
Description

string

Create a new Repo

POST https://api.github.com/user/repos

Request Body

Name
Type
Description

description

string

"This is a test repository created by Postman"

name

string

"Test-Repository"

Check public Repo

GET https://api.github.com/repos/:owner/:repo

Path Parameters

Name
Type
Description

repo

string

Test-Repository

owner

string

testerBartek

Create Issue

POST https://api.github.com/repos/:{owner}/:{repo}/issues

Path Parameters

Name
Type
Description

{repo}

string

Test-Repository

{owner}

string

testerBartek

Request Body

Name
Type
Description

body

string

"This issue has been automatically created by Postman"

title

string

"Found a bug"

Check created Issue

GET https://api.github.com/repos/:{owner}/:{repo}/issues/:{issue_number}

Path Parameters

Name
Type
Description

{issue_number}

string

1

{repo}

string

Test-Repository

{owner}

string

testerBartek

Delete GitHub Repo

DELETE https://api.github.com/repos/:{owner}/:{repo}

Path Parameters

Name
Type
Description

{repo}

string

Test-Repository

{owner}

string

testerBartek

Check deleted Repo

GET https://api.github.com/repos/:{owner}/:{repo}

Path Parameters

Name
Type
Description

{repo}

string

Test-Repository

{owner}

string

testerBartek

Collection and test run

GitHub.postman_collection.json

Last updated

Was this helpful?