API Flashcards

1
Q

What is HTTP verb GET used for?

A

READ - The GET method requests a representation of the specified resource. Requests using GET should only retrieve data.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
2
Q

What is the POST verb used for?

A

CREATE - Used to submit an entity to the specified resource, often causing a change in state or side affects.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
3
Q

What is the PUT verb used for?

A

UPDATE/REPLACE - replaces all current representations of the target resource with the request payload.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
4
Q

What is the DELETE verb used for?

A

Delete - Deletes the specified resource.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
5
Q

IN Web API, what are the two basic Contorller return types

A

IHttpActionResult and HttpResponseMessage

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
6
Q

If a Controller action returns an IHttpActionResult, what method does Web API call to create the HttpResponseMessage?

A

ExecuteAsync

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
7
Q

In .ASP.NET Web API, what is a controller?

A

A class that handles HTTP requests. The public methods of the controller are called action methods or actions.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
8
Q

How is a Web API route formatted?

A

api/controller/possible something here

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
9
Q

Why does api have to be in the route for Web API?

A

To avoid possible collision with ASP.NET MVC

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
10
Q

When receiving a request, how does Web API find the correct action using naming conventions?

A

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.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
11
Q

In WebAPI, what is an alternative to naming conventions to find the correct action?

A

Use an attribute with an HTTP verb such as [HttpGet]

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
12
Q

Can you have multiple http verbs on a controller or custom verbs?

A

Yes, using AcceptVerbs and that’s all you know about that. Ex: [AcceptVerbs(“GET”, “HEAD”)]

How well did you know this?
1
Not at all
2
3
4
5
Perfectly