From the course: Building and Securing RESTful APIs in ASP.NET Core

Unlock the full course today

Join today to access over 22,600 courses taught by industry experts or purchase this course individually.

Serialize the form metadata

Serialize the form metadata - ASP.NET Core Tutorial

From the course: Building and Securing RESTful APIs in ASP.NET Core

Start my 1-month free trial

Serialize the form metadata

- [Instructor] We've built a route that allows the client to create a new booking in the hotel. The JSON body the client sends over the wire is bound to the BookingForm class. However, there's no way for the client to know what field should be submitted in the first place. To solve this problem and make the API truly comply with the HATEOAS constraint, we can generate some metadata about the form and send that to the client. The goal is to return this ion form. We'll return a named form called Book, which includes an HREF to the route the client needs to submit to in order to create the booking. The form also specifies that you should use the POST method to interact with this route. Because we're creating a resource here, we'll send the create form link relation. The value element of the form contains a collection of all of the form field elements. Each one of the form fields that needs to be submitted with this form is included in this value element. For each form field, all of the…

Contents