API Flashcards
(12 cards)
What is HTTP verb GET used for?
READ - The GET method requests a representation of the specified resource. Requests using GET should only retrieve data.
What is the POST verb used for?
CREATE - Used to submit an entity to the specified resource, often causing a change in state or side affects.
What is the PUT verb used for?
UPDATE/REPLACE - replaces all current representations of the target resource with the request payload.
What is the DELETE verb used for?
Delete - Deletes the specified resource.
IN Web API, what are the two basic Contorller return types
IHttpActionResult and HttpResponseMessage
If a Controller action returns an IHttpActionResult, what method does Web API call to create the HttpResponseMessage?
ExecuteAsync
In .ASP.NET Web API, what is a controller?
A class that handles HTTP requests. The public methods of the controller are called action methods or actions.
How is a Web API route formatted?
api/controller/possible something here
Why does api have to be in the route for Web API?
To avoid possible collision with ASP.NET MVC
When receiving a request, how does Web API find the correct action using naming conventions?
To find the action, Web API looks at the HTTP verb, and then looks for an action whose name begins with that HTTP verb name. For example, with a GET request, Web API looks for an action prefixed with “Get”, such as “GetContact” or “GetAllContacts”. This convention applies only to GET, POST, PUT, DELETE, HEAD, OPTIONS, and PATCH verbs.
In WebAPI, what is an alternative to naming conventions to find the correct action?
Use an attribute with an HTTP verb such as [HttpGet]
Can you have multiple http verbs on a controller or custom verbs?
Yes, using AcceptVerbs and that’s all you know about that. Ex: [AcceptVerbs(“GET”, “HEAD”)]