TOP 25+ WEB API INTERVIEW QUESTIONS & ANSWERS 2021

sparrow jack
sparrow jack March 8, 2021
Updated 2021/04/18 at 5:34 AM

Web API Interview Questions

Q1.What is Web API?
Ans-
WebAPI is a framework which helps you to build/develop HTTP services.
Q2.Why is Web API required? Is it possible to use RESTful services using WCF?
Ans-
Yes, we can still develop RESTful services with WCF. However, there are two main reasons that prompt users to use Web API instead of RESTful services.
Web API increases TDD (Test Data Driven) approach in the development of RESTful services.
If we want to develop RESTful services in WCF, you surely need a lot of config settings, URI templates, contracts & endpoints for developing RESTful services using web API.
TOP 25+ WEB API INTERVIEW QUESTIONS & ANSWERS 2021
Q3.Why select Web API?
Ans-
It is used to create simple, non-SOAP-based HTTP Services
It is also an easy method for creation with Web API. With WCF REST Services
It is based on HTTP and easy to define, expose and consume in a REST-ful way.
It is lightweight architecture and ideal for devices that have limited bandwidth like smartphones.
Q4.Is it right that ASP.NET Web API has replaced WCF?
Ans-
It’s a not at all true that ASP.NET Web API has replaced WCF. In fact, it is another way of building non-SOAP based services, i.e., plain XML or JSON string.
Q5.What are the advantages of Web API?
Ans-
Advantages of Web API are:
OData
Filters
Content Negotiation
Self-Hosting
Routing
Model Bindings
Q6.What is SOAP?
Ans-
SOAP is an XML message format used in web service interactions. It allows to send messages over HTTP or JMS, but other transport protocols can be used. It is also an XML-based messaging protocol for exchanging information among computers.
Q7.What is the benefit of using REST in Web API?
Ans-
REST is used to make fewer data transfers between client and server which make it an ideal for using it in mobile apps. Web API also supports HTTP protocol. Therefore, it reintroduces the traditional way of the HTTP verbs for communication.
Q8.How can we use Web API with ASP.NET Web Form?
Ans-
Web API can be used with ASP.NET Web Form
It can be performed in three simple steps:
Create a Web API Controller,
Add a routing table to Application_Start method of Global.sax
Then you need to make a jQuery AJAX Call to Web API method and get data.

Web API Interview Questions For Freshers

Q9.How to you can limit Access to Web API to Specific HTTP Verb?
Ans-
Attribute programming plays a important role. It is easy to restrict access to an ASP.NET Web API method to be called using a particular HTTP method.
Q10.Can you use Web API with ASP.NET Web Form?
Ans-
Yes, It is possible to use Web API with ASP.Net web form. As it is bundled with ASP.NET MVC framework. However, it can be used with ASP.NET Web Form.
Q11.What are main return types supported in Web API?
Ans-
A Web API controller action can return following values:
Void – It will return empty content
HttpResponseMessage – It will convert the response to an HTTP message.
IHttpActionResult – internally calls ExecuteAsync to create an HttpResponseMessage
Other types – You can write the serialized return value into the response body
Q12.Web API supports which protocol?
Ans-
Web App supports HTTP protocol.
Q13.Which .NET framework supports Web API?
Ans-
NET 4.0 and above version supports web API.
Q14.Web API uses which of the following open-source library for JSON serialization?
Ans-
Web API uses library for JSON serialization.
Q15.By default, Web API sends HTTP response with which of the following status code for all uncaught exception?
Ans-
500 – Internal Server Error
Q16.What is the biggest disadvantage of “Other Return Types” in Web API?
Ans-
The biggest disadvantage of this approach is that you cannot directly return an error code like 404 error.
Q17.What is the meaning of TestApi?
Ans-
TestApi is a utility library of APIs. Using this library tester developer can create testing tools and automated tests for a .NET application using data-structure and algorithms.

Web API Interview Questions For Experienced

Q18.Explain exception filters?
Ans-
It will be executed when exceptions are unhandled and thrown from a controller method. The reason for the exception can be anything. Exception filters will implement “IExceptionFilter” interface.
Q19.How you can return View from ASP.NET Web API method?
Ans-
No, we can’t return a view from ASP.NET Web API Method. Web API creates HTTP services that render raw data. However, it’s also possible in ASP.NET MVC application.
Q20.How to register exception filter globally?
Ans-
It is possible to register exception filter globally using following code-
GlobalConfiguration.Configuration.Filters.Add(new MyTestCustomerStore.NotImplExceptionFilterAttribute());
Q21.Explain what is REST and RESTFUL?
Ans-
REST represents REpresentational  State Transfer; it is entirely a new aspect of writing a web app.
RESTFUL: It is term written by applying REST architectural concepts is called RESTful services. It focuses on system resources and how the state of the resource should be transported over HTTP protocol.
Q22.Web API supports which protocol?
Ans-
Web App support HTTP protocol
Q23.Which of the following .NET framework supports Web API?
Ans-
Web API is supported by NET 4.0 version
Q24.Web API uses which library for JSON serialization?
Ans-
Web API uses Json.NET library for JSON serialization.
Q25.By default, Web API sends HTTP response with which of the following status code for all uncaught exception?
Ans-
500 – Internal Server Error
Q26.Explain method to handle error using HttpError in Web API?
Ans-
In WEB API HttpError used to throw the error info in the response body. “CreateErrorResponse” method is can also use along with this, which is an extension method defined in “HttpRequestMessageExtension.”
Share this Article
Leave a comment

Leave a Reply

Your email address will not be published. Required fields are marked *