Please enable Javascript for better experience...
Web API Tutorial C# - Part 4: Testing Web API using Postman
By Rahul Kumar Jha | Jan 4, 2020 | In Tutorials | Total Views [ 10239 ]
Taged In
(3 Like)
Rate

This is part 4 of Web API Tutorial series. In this tutorial, you will learn testing Web API using Postman. In this tutorial, we will test Bearer authentication using Postman.

Introduction

In last chapters, you learnt creating MVC + Web API application and implemented Bearer authentication using custom authentication filter. In this chapter, you will learning testing Web API using Postman. Before we start, let me tell you something about Postman. There are n numbers of tools available for testing RESTful services but Postman is globally accepted tool for testing because of its features and user-friendly UI. In this tutorial, we have use Postman to test Bearer authentication. Please follow below steps or watch this video, it has same steps what is explained in below sections.

Overview of Postman

Before we start, let's take an overview of Postman tool. In Postman, there are many options which we can apply why testing our API. You can create a new request to test your service, create new collection for set of request, you can also create an environment to run your service. Postman gives you many features which enable to test your API service very efficiently and very effectively without overheaded configurations. You can choose any verb from pre-defined set of options according to your requirement.

01

Below you can see the list of HTTP verbs available in Postman.

02

Setting Bearer Token in Authorization Parameter

Now let's create a GET request and add Bearer token in Authorization parameter. For that, follow below steps.

  • Click (+) sign or click on New Request.
  • Select HTTP GET verb from available options and add service URL.
  • Now in Authorization tab, select type as Bearer Token and in right side enter token value.
  • Click Preview request.

03

Now in Header tab, click on Temporary Headers. Here notice that token has been added as value for Authorization key.

04

Click Send button.

Now notice that more key-value added in header section. It contains request information like host, user-agent, cache, authorization and so on.

05

Now,click on Body tab. Here you can see the sevice response in JSON format.

06

I believe, it was no so tough. Hope this helps you.
<< Web API Tutorial C# - Part 3: Implementing basic Bearer authentication in Web API application
Web API Tutorial C# [Part 5] - Fetching data from SQL Server into Web API >>

Share this

About the Author

Rahul Kumar Jha
Rahul Kumar Jha
Founder, Developer dotnet-concept.com

Public profile: user/profile/99900001


Has working experience in different phases of Software Development Life Cycle (SDLC) in CMS, Gaming, Health Care and Financial Services domain using Agile pattern. Working experience in Design patterns, ASP.NET, MVC, ANGULAR, ANGULAR JS, Windows application, WCF, ADO.NET, SQL Server and Test Driven Development (TDD) environment with JQuery, JavaScript, N-Unit, Entity Frameworks, LINQ, Code Refactoring and Business Objects Models.

User's Comments


 
Please SignUp/Login to comment...

Or comment as anonymous...
* Name
* Email ID
Comment
 
 
 
 
 
 
Sponsors