From the course: Building and Securing Restful APIs in .NET

Unlock the full course today

Join today to access over 24,800 courses taught by industry experts.

Implement resource PUT

Implement resource PUT

- [Instructor] Now that we can create an employee, we also want to go back and be able to potentially update an employee, and we'll do that with a put operation. I'm going to take everything we used in our post, I'm going to copy it and I'm going to come down here to the put and I'm going to replace that signature, making sure that I go up here and change the operation name so I have a different one. You notice I didn't take the attribute on line 72. I kept that to say that this operation is an HTTP put operation with an ID. So in that signature, then, not only do I need the particular resource that represents it, but I also need the id. So that's, again, going to be part of the URI that's going to get passed in in that URL, and the body is going to contain the resource, that employee that we're going to update. We'll do the same thing we did before with the post, line 78. If the model state isn't valid, we're going to return a client error. So we're going to indicate that that's a…

Contents