0% found this document useful (0 votes)
20 views6 pages

Build RESTful Services with Postman

The document outlines a procedure for building RESTful web services using Node.js and testing them with the Postman tool. It includes steps for installing Node.js, setting up a project, creating an Express application, and testing API endpoints. The process concludes with a successful demonstration of retrieving book data via Postman.

Uploaded by

jiteshraaju
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
20 views6 pages

Build RESTful Services with Postman

The document outlines a procedure for building RESTful web services using Node.js and testing them with the Postman tool. It includes steps for installing Node.js, setting up a project, creating an Express application, and testing API endpoints. The process concludes with a successful demonstration of retrieving book data via Postman.

Uploaded by

jiteshraaju
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd

JITESHRAAJU

R 22IT038

Exp 2B BUILDING RESTFULWEB SERVICES- TESTING WITH

08.07.24 POSTMAN TOOL

AIM:
To bulid RESTful web services and testing it with Postman Tool.
PROCEDURE:

1. Install [Link] by clicking the below link.


[Link]

2. After installing [Link] you could getSetup Wizard in that click Next.

3. Click Install.

4. Click Finish.
JITESHRAAJU
R 22IT038

After installation completed.

1. Open Command Prompt and type the Command

Cmd – node - v

Cmd – npm - v
To check Installations

2. Type the command

Cmd – init -y
JITESHRAAJU
R 22IT038

3. After running the above command now you could see [Link] file the
directory

4. Type the command

Cmd – npm install express nodemon


JITESHRAAJU
R 22IT038

5. Create a file [Link] with the following code. const express =

require('express'); // This line imports the Express module const Joi =


require('joi'); // used for validation const app = express(); // creates an
instance of express application const bodyParser = require('body-parser'); //
parse incoming request bodies [Link]([Link]()); // express
application will use inbuilt json function

const books = [
{ title: 'Harry Potter', id: 1 },
{ title: 'Twilight', id: 2 },
{ title: 'Lorien Legacies', id: 3 } ];
// defines array of books

[Link]('/', (req, res) =>


{ [Link]('REST APIs are so much
fun'); }); // route handler – sends a
response

[Link]('/api/books', (req, res) =>


{ [Link](books);
});

[Link]('/api/books/:id', (req, res) => { const book = [Link](c =>


[Link] === parseInt([Link])); if (!book)
{ [Link](404).send( '<h2 style="font-family: Malgun Gothic;
color: darkred;">Ooops... Cant find what you are looking for!</h2>'); }
[Link](book);
});
JITESHRAAJU
R 22IT038

const port = [Link] || 8081;


[Link](port, () => [Link](`Listening on port ${port}..`));

After saving the file type node [Link] in the command prompt.

7. Download the postman tool from the below link


[Link] /

8. Now Type the [Link] / and Get and click Send button.
JITESHRAAJU
R 22IT038

9. You could get the output below.

RESULT:
Thus building a RESTful web services and testing it with Postman Tool is
completed successfully.

You might also like