Skip to content
This repository was archived by the owner on Dec 9, 2021. It is now read-only.

A basic Postman example

Notifications You must be signed in to change notification settings

DigiPR/digipr-postman-example

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

6 Commits
 
 

Repository files navigation

Postman Example

This example illustrates how a REST API can be called with the help of Postman.

Contents:

Pre-requisite: Postman

This guide is going to illustrate how API engineering and testing can be done using the API development environment Postman.

You can download Postman from here: https://www.getpostman.com/apps

Task: Make a Sample Call

The only task in this little example is to call the following Echo-Endpoint with the help of Postman:

Echo-Endpoint

URL: https://www.putsreq.com/tGemy9dwjunY1e19JcLt

Method: POST

Sample RequestHeader: Content-Type: application/jsonBody:

{
    "variableA": "Data A",
    "variableB": "Data B",
    "businessKey": "case-001"
}

Optional: businessKey

Success ResponseCode: 200 OKSample Body:

{
    "variableA": "Data A ECHO!!!",
    "variableB": "Data B ECHO!!!",
    "businessKey": "case-001"
}

Error ResponseCode: 404 NOT FOUND

Try to figure out how this information can be used to call the Echo-Endpoint in Postman.

Echo Endpoint on PutsReq

This is optional: Just in case the predefined endpoint is not working or may want to create an own instantiation.

You may create an own version of the Echo-Endpoint on PutsReq using the following script:

if (request.headers['CONTENT-TYPE']!='application/json') {
        response.status = 404;
        response.headers = {};
        response.body = 'no JSON body';
} else {
    parsedBody = JSON.parse(request.body);
        
    if (parsedBody.variableA && parsedBody.variableB) {
        response.status = 200;
        response.headers['Content-Type'] = 'application/json';
        response.body = {
            variableA: parsedBody.variableA + " ECHO!!!",
            variableB: parsedBody.variableB  + " ECHO!!!",
            businessKey: parsedBody.businessKey // optional
        };
    } else {
        response.status = 404;
        response.headers = {};
        response.body = 'not found';
    }
}

About

A basic Postman example

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published