Skip to main content

BCT Prac

Updated 18 min readMarkdown

BCT

*Practical 1*
Aim: Create new block with data and test the block
Code:
const SHA256 = require("sha256");
class Block{
    constructor(index, timestamp, data, previousHash = ''){
        this.index = index;
        this.timestamp = timestamp;
        this.data = data;
        this.previousHash = previousHash;
        this.hash = this.calculateHash();
    }
    calculateHash(){
        return SHA256(this.index + this.previousHash + this.timestamp + JSON.stringify(this.data)).toString();
    }
}
class Blockchain{
    constructor(){
        this.chain = [this.createGenesisBlock()];
    }
    createGenesisBlock(){
        return new Block(0, "01/01/2017", "Genesis block", "0");
    }
    getLatestBlock(){
        return this.chain[this.chain.length-1];
    }
    addBlock(newBlock){
        newBlock.previousHash = this.getLatestBlock().hash;
        newBlock.hash = newBlock.calculateHash();
        this.chain.push(newBlock);
    }
}
let firbitCoin = new Blockchain();
firbitCoin.addBlock(new Block(1,"10/07/2017", {amount: 4}));
firbitCoin.addBlock(new Block(2,"12/07/2017", {amount: 10}));
console.log(JSON.stringify(firbitCoin, null, 4));

OUTPUT:        

 
********************************Practical 2**************************************
Aim: Create a new transaction
Code:
const SHA256 = require("sha256");
class Transaction {
    constructor(fromAddress, toAddress, amount) {
        this.fromAddress = fromAddress;
        this.toAddress = toAddress;
        this.amount = amount;
    }
}
class Block {
    constructor(timestamp, transactions, previousHash = "") {
        this.timestamp = timestamp;
        this.transactions = transactions;
        this.previousHash = previousHash;
        this.hash = this.calculateHash();
        this.nonce = 0;
    }
    calculateHash() {
        return SHA256(this.index + this.previousHash + JSON.stringify(this.data) + this.nonce).toString();
    }
    mineBlock(difficulty) {
        while (this.hash.substring(0, difficulty) !== Array(difficulty + 1).join("0")) {
            this.nonce++;
            this.hash = this.calculateHash();
        }
        console.log("Block Mined: " + this.hash);
    }
}
class Blockchain {
    constructor() {
        this.chain = [this.createGenesisBlock()];
        this.difficulty = 2;
        this.pendingTransactions = [];
        this.miningReward = 100;
    }
    createGenesisBlock() {
       return new Block(0, "18/10/2023", "Genesis block", "0");
    }
  getLatestBlock() {
        return this.chain[this.chain.length - 1];
    }
    minePendingTransaction(miningAdress) {
        let block = new Block(Date.now(), this.pendingTransactions);
        block.mineBlock(this.difficulty);
        console.log("Block mined successfully!");
        this.chain.push(block);
        this.pendingTransactions = [
            new Transaction(null, miningAdress, this.miningReward)
        ];
    }
    createTransaction(transaction) {
        this.pendingTransactions.push(transaction);
    }
getBalanceOfAddress(address) {
        let balance = 0;
        for (const block of this.chain) {
            for (const trans of block.transactions) {
                if (trans.fromAddress === address) {
                    balance -= trans.amount;
                }
                if (trans.toAddress === address) {
                    balance += trans.amount;
                }
            }
        }
        return balance;
    }
}
let firstBitCoin = new Blockchain();
console.log('Starting the miner...');
firstBitCoin.minePendingTransaction('vinit');
console.log('\nBalance of Faria is ', firstBitCoin.getBalanceOfAddress('faria'))
firstBitCoin.createTransaction(new Transaction("vinit", "faria", 20));
console.log('\nBalance of Vinit is ', ((firstBitCoin.getBalanceOfAddress('vinit')) + 100));
console.log('Starting the miner...');
firstBitCoin.minePendingTransaction('vinit');
console.log('\nBalance of Vinit is ', firstBitCoin.getBalanceOfAddress('vinit'))
console.log('\nStarting the miner again...');
firstBitCoin.minePendingTransaction('faria');
console.log('\nBalance of Faria is ', firstBitCoin.getBalanceOfAddress('faria'))

OUTPUT:


 
******************************Practical 3**************************************
Aim: Hash block and Hash function Genesis block.
Code:
const SHA256 = require("sha256")
class Block{
    constructor(index, timestamp, data, previousHash = ''){
        this.index = index;
        this.timestamp = timestamp;
        this.data = data;
        this.previousHash = previousHash;
        this.hash = this.calculateHash();
    }
    calculateHash(){
        return SHA256(this.index + this.previousHash + this.timestamp + JSON.stringify(this.data)).toString();
    }
}
class Blockchain{
    constructor(){
        this.chain = [this.createGenesisBlock()];
    }
    createGenesisBlock(){
        return new Block(0, "01/01/2023", "Genesis block", "0");
    }
    getLatestBlock(){
        return this.chain[this.chain.length - 1];
    }

    addBlock(newBlock){
        newBlock.previousHash = this.getLatestBlock().hash;
        newBlock.hash = newBlock.calculateHash();
        this.chain.push(newBlock);
    }
}
let firstCoin = new Blockchain();
console.log(JSON.stringify(firstCoin, null, 4));
OUTPUT:


******************************Practical 4************************************
Aim: Proof of work. 
Code:
const SHA256 = require("sha256");
class Block{
    constructor(index, timestamp, data, previousHash = ''){
        this.index = index;
        this.timestamp = timestamp;
        this.data = data;
        this.previousHash = previousHash;
        this.hash = this.calculateHash();
        this.nonce = 0;
    }
    calculateHash(){
        return SHA256(this.index + this.previousHash + this.timestamp + JSON.stringify(this.data) + this.nonce).toString();
    }
    mineBlock(difficulty){
        while(this.hash.substring(0,difficulty) !== Array(difficulty + 1).join("0")){
            this.nonce++;
            this.hash = this.calculateHash();
        }
        console.log("Block mined: " + this.hash);
    }
}
class Blockchain{
    constructor(){
        this.chain = [this.createGenesisBlock()];
        this.difficulty = 2;
    }
    createGenesisBlock(){
        return new Block(0, "01/01/2017", "Genesis block", "0");
    }
    getLatestBlock(){
        return this.chain[this.chain.length-1];
    }
    addBlock(newBlock){
        newBlock.previousHash = this.getLatestBlock().hash;
        newBlock.mineBlock(this.difficulty);
        this.chain.push(newBlock);
    }
}
let firbitCoin = new Blockchain();
console.log('Mining block 1');
firbitCoin.addBlock(new Block(1,"10/07/2017", {amount: 4}));
console.log('Mining block 2');
firbitCoin.addBlock(new Block(2,"12/07/2017", {amount: 10}));
 

OUTPUT:
Difficulty = 4

Difficulty = 2

 
*************************Practical 5****************************************
Aim: Genesis block
Code:
const SHA256 = require("sha256")
class Block{
    constructor(index, timestamp, data, previousHash = ''){
        this.index = index;
        this.timestamp = timestamp;
        this.data = data;
        this.previousHash = previousHash;
        this.hash = this.calculateHash();
    }
    calculateHash(){
        return SHA256(this.index + this.previousHash + this.timestamp + JSON.stringify(this.data)).toString();
    }
}
class Blockchain{
    constructor(){
        this.chain = [this.createGenesisBlock()];
    }
    createGenesisBlock(){
        return new Block(0, "01/01/2023", "Genesis block", "0");
    }
}
let firstCoin = new Blockchain();
console.log(JSON.stringify(firstCoin, null, 4));

Output:


 
**********************************Practical 6******************************
Aim: Blockchain Endpoints
Code:
const SHA256 = require("sha256");
class Block{
    constructor(index, timestamp, data, previousHash = ''){
        this.index = index;
        this.timestamp = timestamp;
        this.data = data;
        this.previousHash = previousHash;
        this.hash = this.calculateHash();
    }
    calculateHash(){
        return SHA256(this.index + this.previousHash + this.timestamp + JSON.stringify(this.data)).toString();
    }
}
class Blockchain{
    constructor(){
        this.chain = [this.createGenesisBlock()];
    }
    createGenesisBlock(){
        return new Block(0, "01/01/2017", "Genesis block", "0");
    }
    getLatestBlock(){
        return this.chain[this.chain.length-1];
    }
    addBlock(newBlock){
        newBlock.previousHash = this.getLatestBlock().hash;
        newBlock.hash = newBlock.calculateHash();
        this.chain.push(newBlock);
    }
}
let firbitCoin = new Blockchain();
firbitCoin.addBlock(new Block(1,"10/07/2017", {amount: 4}));
firbitCoin.addBlock(new Block(2,"12/07/2017", {amount: 10}));
console.log(JSON.stringify(firbitCoin, null, 4));    
    addBlock(newBlock){
        newBlock.previousHash = this.getLatestBlock().hash;
        newBlock.hash = newBlock.calculateHash();
        this.chain.push(newBlock);
    }
}
let firstCoin = new Blockchain();
firstCoin.addBlock(new Block(1, "10/9/2023", {amount : 4}));
firstCoin.addBlock(new Block(2, "10/10/2023", {amount : 14}));
console.log(JSON.stringify(firstCoin, null, 4));

OUTPUT: 


****************************************Practical 7********************************
Aim: Mining block via API.
Code:
const SHA256 = require("sha256")
class Block {
    constructor(index, timestamp, data, previousHash = '') {
        this.index = index;
        this.timestamp = timestamp;
        this.data = data;
        this.previousHash = previousHash;
        this.hash = this.calculateHash();
        this.nonce = 0;
    }
    calculateHash() {
        return SHA256(this.index + this.previousHash + this.timestamp + JSON.stringify(this.data) + this.nonce).toString();
    }
    mineBlock(difficulty) {
        while (this.hash.substring(0, difficulty) != Array(difficulty + 1).join("0")) {
            this.nonce++;
            this.hash = this.calculateHash();
        }
        console.log("Block Mined: " + this.hash);
    }
}
class Blockchain {
    constructor() {
        this.chain = [this.createGenesisBlock()];
        this.difficulty = 2;
        // this.difficulty = 4;
    }
    createGenesisBlock() {
        return new Block(0, "01/01/2023", "Genesis block", "0");
    }

    getLatestBlock() {
        return this.chain[this.chain.length - 1];
    }
    addBlock(newBlock) {
        newBlock.previousHash = this.getLatestBlock().hash;
        newBlock.mineBlock(this.difficulty);
        this.chain.push(newBlock);
    }
}
let firstCoin = new Blockchain();
console.log("Mining Block 1");
firstCoin.addBlock(new Block(1, "10/3/2023", { amount: 4 }));
// console.log("Mining Block 2")
firstCoin.addBlock(new Block(2, "10/10/2023", { amount: 14 }));
console.log(JSON.stringify(firstCoin, null, 4));

OUTPUT:

**********************************#THEORY#*******************************

*********************************PRACTICAL 1*************************** 

What is Node.js? 
Node.js is an open-source server side runtime environment built on Chrome's V8 JavaScript engine. It provides an event driven, non-blocking (asynchronous) I/O and cross-platform runtime environment for building highly scalable serverside application using JavaScript. 
Node.js can be used to build different types of applications such as command line application, web application, realtime chat application, REST API server etc. However, it is mainly used to build network programs like web servers, similar to PHP, Java, or ASP.NET. 

Node.js development environment can be setup in Windows, Mac, Linux and Solaris. The following tools/SDK are required for developing a Node.js application on any platform. 
1.    Node.js 
2.    Node Package Manager (NPM) 
3.    IDE (Integrated Development Environment) or TextEditor 

NPM (Node Package Manager) is included in Node.js installation since Node version 0.6.0., so there is no need to install it separately. 
Node.js comes with virtual environment called REPL (aka Node shell). REPL stands for Read-Eval-Print-Loop. It is a quick and easy way to test simple Node.js/JavaScript code. 
Node.js supports JavaScript. So, JavaScript syntax on Node.js is similar to the browser's JavaScript syntax. 

Primitive Types 
Node.js includes following primitive types: 
•    String 
•    Number 
•    Boolean 
•    Undefined 
•    Null 
•    RegExp 
Everything else is an object in Node.js. 

Loose Typing 
JavaScript in Node.js supports loose typing like the browser's JavaScript. Use var keyword to declare a variable of any type. 

Object Literal 
Object literal syntax is same as browser's JavaScript. 
Example: Object 
 Copy 
var obj = { 
authorName:'Ryan Dahl',     language: 'Node.js' 
} 

Functions 
Functions are first class citizens in Node's JavaScript, similar to the browser's JavaScript. A function can have attributes and properties also. It can be treated like a class in JavaScript. 
Example: Function  Copy 
function Display(x) {      console.log(x); 
} 

Display(100); 

Buffer 
Node.js includes an additional data type called Buffer (not available in browser's JavaScript). Buffer is mainly used to store binary data, while reading from a file or receiving packets over the network. 

process object 
Each Node.js script runs in a process. It includes process object to get all the information about the current process of Node.js application. 
The following example shows how to get process information in REPL using process object. 
 > process.execPath
'C:\\Program Files\\nodejs\\node.exe'
> process.pid
1652
> process.cwd()
'C:\\'

Defaults to local 
Node's JavaScript is different from browser's JavaScript when it comes to global scope. In the browser's JavaScript, variables declared without var keyword become global. In Node.js, everything becomes local by default. 

Access Global Scope 
In a browser, global scope is the window object. In Node.js, global object represents the global scope. 
To add something in global scope, you need to export it using export or module.export. The same way, import modules/object using require() function to access it from the global scope. 
For example, to export an object in Node.js, use exports.name = object. Example:  
Copy exports.log = {     
       console: function(msg) { 
        console.log(msg); 
    }, 
    file: function(msg) { 
        // log to file here 
      } 
} 
Now, you can import log object using require() function and use it anywhere in your Node.js project. 

Node.js Module 
Module in Node.js is a simple or complex functionality organized in single or multiple JavaScript files which can be reused throughout the Node.js application. 
Each module in Node.js has its own context, so it cannot interfere with other modules or pollute global scope. Also, each module can be placed in a separate .js file under a separate folder. 

Node.js Module Types 
Node.js includes three types of modules: 
1.    Core Modules 
2.    Local Modules 
3.    Third Party Modules 
Node.js Core Modules 
Node.js is a light weight framework. The core modules include bare minimum functionalities of Node.js. These core modules are compiled into its binary distribution and load automatically when Node.js process starts. However, you need to import the core module first in order to use it in your application. 

The following table lists some of the important core modules in Node.js. 
Core Module     Description 
http 
http module includes classes, methods and events to create Node.js http server. 

url 
url module includes methods for URL resolution and parsing. 

querystring 
querystring module includes methods to deal with query string. 

Core Module     Description     
path 
path module includes methods to deal with file paths.     

fs 
fs module includes classes, methods, and events to work with file I/O.     

util 
util module includes utility functions useful for programmers.     


Loading Core Modules 
In order to use Node.js core or NPM modules, you first need to import it using require() function as shown below. 
var module = require('module_name'); 
As per above syntax, specify the module name in the require() function. The require() function will return an object, function, property or any other JavaScript type, depending on what the specified module returns. The following example demonstrates how to use Node.js http module to create a web server. 
var http = require('http'); 

var server = http.createServer(function(req, res){ 

  //write code here 

}); 

server.listen(5000);  
In the above example, require() function returns an object because http module returns its functionality as an object, you can then use its properties and methods using dot notation e.g. http.createServer(). 
Node.js Local Module 
Local modules are modules created locally in your Node.js application. These modules include different functionalities of your application in separate files and folders. You can also package it and distribute it via NPM, so that Node.js community can use it. For example, if you need to connect to MongoDB and fetch data then you can create a module for it, which can be reused in your application. 

Loading Local Module 
To use local modules in your application, you need to load it using require() function in the same way as core module. However, you need to specify the path of JavaScript file of the module. 
Node.js Web Server 
To access web pages of any web application, you need a web server. The web server will handle all the http requests for the web application e.g IIS is a web server for ASP.NET web applications and Apache is a web server for PHP or Java web applications. 
Node.js provides capabilities to create your own web server which will handle HTTP requests asynchronously. You can use IIS or Apache to run Node.js web application but it is recommended to use Node.js web server. 

Create Node.js Web Server 
Node.js makes it easy to create a simple web server that processes incoming requests asynchronously. 
var http = require('http'); // 1 - Import Node.js core module 

var server = http.createServer(function (req, res) {   // 2 - creating server 

    //handle incomming requests here.. 

}); 

server.listen(5000); //3 - listen for any incoming requests 

console.log('Node.js web server at port 5000 is running..') 
In the above example, we import the http module using require() function. The http module is a core module of Node.js, so no need to install it using NPM. The next step is to call createServer() method of http and specify callback function with request and response parameter. Finally, call listen() method of server object which was returned from createServer() method with port number, to start listening to incoming requests on port 5000. You can specify any unused port here. Run the above web server by writing node server.js command in command prompt or terminal window and it will display message as shown below.
C:\> node server.js
Node.js web server at port 5000 is running..

Handle HTTP Request 
The http.createServer() method includes request and response parameters which is supplied by Node.js. The request object can be used to get information about the current HTTP request e.g., url, request header, and data. The response object can be used to send a response for a current HTTP request. 
The following example demonstrates handling HTTP request and response in Node.js. 
var http = require('http'); // Import Node.js core module 
var server = http.createServer(function (req, res) {   //create web server     if (req.url == '/') { //check the URL of the current request  
        // set response header 
        res.writeHead(200, { 'Content-Type': 'text/html' });  

        // set response content     
res.write('<html><body><p>This is home Page.</p></body></html>');         res.end();       
} 
    else if (req.url == "/student") {    
        res.writeHead(200, { 'Content-Type': 'text/html' }); 
        res.write('<html><body><p>This is student Page.</p></body></html>');               
        res.end();         
} 
    else if (req.url == "/admin") {          
        res.writeHead(200, { 'Content-Type': 'text/html' }); 
        res.write('<html><body><p>This is admin Page.</p></body></html>');           
        res.end();          
}     else 
        res.end('Invalid Request!'); 

}); 
server.listen(5000); //6 - listen for any incoming requests 

console.log('Node.js web server at port 5000 is running..') 

In the above example, req.url is used to check the url of the current request and based on that it sends the response. To send a response, first it sets the response header using writeHead() method and then writes a string as a response body using write() method. Finally, Node.js web server sends the response using end() method. Now, run the above web server as shown below. 
 C:\> node server.js
Node.js web server at port 5000 is running..


Frameworks for Node.js 
There are various third party open-source frameworks available in Node Package Manager which makes Node.js application development faster and easy. You can choose an appropriate framework as per your application requirements. 
The following table lists frameworks for Node.js. 
Open-Source Framework     Description 
Express.js 
Express is a minimal and flexible Node.js web application framework that provides a robust set of features for web and mobile applications. This is the most popular framework as of now for Node.js. 

Geddy 
Geddy is a simple, structured web application framework for Node.js based on MVC architecture. 

Locomotive 
Locomotive is MVC web application framework for Node.js. It supports MVC patterns, RESTful routes, and convention over configuration, while integrating seamlessly with any database and template engine. Locomotive builds on Express, preserving the power and simplicity you've come to expect from Node. 

Koa 
Koa is a new web framework designed by the team behind Express, which aims to be a smaller, more expressive, and more robust foundation for web applications and APIs. 

Total.js 
Totaljs is free web application framework for building web sites and web applications using JavaScript, HTML and CSS on Node.js 

Hapi.js 
Hapi is a rich Node.js framework for building applications and services. 

Keystone 
Keystone is the open source framework for developing database-driven websites, applications and APIs in Node.js. Built on Express and MongoDB. 

Derbyjs 
Derby support single-page apps that have a full MVC structure, including a model provided by Racer, a template and styles based view, and controller code with application logic and routes. 

Sails.js 
Sails makes it easy to build custom, enterprise-grade Node.js apps. It is designed to emulate the familiar MVC pattern of frameworks like Ruby on Rails, but with support for the requirements of modern apps: data-driven APIs with a scalable, service-oriented architecture. It's especially good for building chat, realtime dashboards, or multiplayer games; but you can use it for any web application project - top to bottom. 

Meteor 
Meteor is a complete open source platform for building web and mobile apps in pure JavaScript.

Mojito 
This HTML5 framework for the browser and server from Yahoo offers direct MVC access to the server database through the local routines. One clever feature allows the code to migrate. If the client can't run JavaScript for some reason, Mojito will run it on the server -- a convenient way to handle very thin clients. 

Restify 
Restify is a node.js module built specifically to enable you to build correct REST web services.

Open-Source Framework     Description      

Loopback 
Loopback is an open-source Node.js API framework.     

ActionHero 
actionhero.js is a multi-transport Node.JS API Server with integrated cluster capabilities and delayed tasks.     

Frisby 
Frisby is a REST API testing framework built on node.js and Jasmine that makes testing API endpoints easy, fast, and fun.     

Chocolate.js 
Chocolate is a simple webapp framework built on Node.js using Coffeescript.     





Data Access in Node.js 
Node.js supports all kinds of databases no matter if it is a relational database or NoSQL database. However, NoSQL databases like MongoDb are the best fit with Node.js. 
To access the database from Node.js, you first need to install drivers for the database you want to use. The following table lists important relational databases and respective drivers. 



 

PRACTICAL 2 

Postman is an Application Programming Interface (API) testing tool. API acts like an interface between a couple of applications and establishes a connection between them. It can be used to design, document, verify, create, and change APIs. Postman has the feature of sending and observing the Hypertext Transfer Protocol (HTTP) requests and responses. It has a graphical user interface (GUI) and can be used in platforms like Linux, Windows and Mac. It can build multiple HTTP requests − POST, PUT, GET, PATCH and translate them to code. 
Postman, have the navigations as shown below. It primarily consists of four sections − 
•    Header 
•    Response 
•    Sidebar 
•    Builder 
Header 
Postman consists of New, Import, Runner (used to execute tests with Collection Runner), Open New, Interceptor, Sync menus, and so on. It shows the workspace name – My Workspace along with the option for Invite for sharing it among teams. 

New menu is used to create a new Environment, Collection or request. The Import menu helps to import an  Environment /Collection. 
Response 
Response section shall have values populated only when a request is made. It generally contains the Response details. 
Sidebar 
Sidebar consists of Collections (used to maintain tests, containing folders, sub-folders, requests), History (records all API requests made in the past), and APIs. 
Builder 
Builder is the most important section of the Postman application. It has the request tab and displays the current request name. By default, Untitled Request is mentioned if no title is provided to a request. The Builder section also contains the request type (GET, POST, PUT, and so on) and URL. 
The Builder section has the tabs like Param, Authorization, Headers, Body, Pre-req., Tests and Settings. The parameters of a request in a key-value pair are mentioned within the Params tab. The Authorization for an API with username, password, tokens, and so on are within the Authorization tab. 
The request headers, body are defined within the Headers and Body tab respectively. Sometimes, there are pre-condition scripts to be executed prior to a request. These are mentioned within the Pre-req. tab. 
The Tests tab contains scripts that are run when a request is triggered. This helps to validate if the API is working properly and the obtained data and Response code is correct. 
Environment Variables 
Variables give the option to hold and repeat parameters in the requests, collections, and scripts and so on. If we need to modify a value, we need to do it in only one place. Thus, the variables help to minimize the chance of errors and increase efficiency. 
In Postman, an environment consists of a key-value pair. It helps to identify each request separately. As we create environments, we can modify key-value pairs and that will produce varied responses from the same request. 
The key in the key−value pair in the environment is known as the Environment variable. There can be multiple environments and each of them can also have multiple variables. However, we can work with a single environment at one time. 
In short, an environment allows the execution of requests and collections in a varied data set. We can create environments for production, testing and development. Each of these environments will have different parameters like URL, password, and so on. 
Environment Variables Scope 
The scope of an Environment variable is within the environment for which it is created. This means it has a local scope confined to that environment. If we select another environment, and try to access the same Environment variable, we shall get an error. 
Postman - Authorization 
In Postman, authorization is done to verify the eligibility of a user to access a resource in the server. There could be multiple APIs in a project, but their access can be restricted only for certain authorized users. 
The process of authorization is applied for the APIs which are required to be secured. This authorization is done for identification and to verify, if the user is entitled to access a server resource. 
Postman - Workflows 
In a Postman Collection, the requests are executed in the order in which they appear. Every request is run first by the order of the folder followed by any request at the Collection root. 
Postman - Create Collections 
A group of requests that have been saved and organized into folders is known as the Collections. It is similar to a repository. Thus, Collections help to maintain the API tests and also split them easily with teams. 
Postman - GET Requests 
A GET request is used to obtain details from the server and does not have any impact on the server. The GET request does not update any server data while it is triggered. The server only sends its Response to the request. 
Postman - POST Requests 
Postman POST request allows appending data to the endpoint. This is a method used to add information within the request body in the server. It is commonly used for passing delicate information. 
Once we send some the request body via POST method, the API in turn yields certain information to us in Response. Thus, a POST request is always accompanied with a body in a proper format. 
Postman - PUT Requests 
A Postman PUT request is used to pass data to the server for creation or modification of a resource. The difference between POST and PUT is that POST request is not idempotent. 
This means invoking the same PUT request numerous times will always yield the same output. But invoking the same POST request numerous times will create the similar resource more than one time. 
Before creating a PUT request, we shall first send a GET request to the server on an endpoint. 
Postman - DELETE Requests 
Postman DELETE request deletes a resource already present in the server. The DELETE method sends a request to the server for deleting the request mentioned in the endpoint. Thus, it is capable of updating data on the server. Before creating a DELETE request, we shall first send a GET request to the server on the endpoint

No comments yet. Be the first to comment.