Consider the following model I use inside the MVC structure:
public class Collection{ /// <summary> /// The UUID of this Collection /// </summary> public required string Id { get; set; } /// <summary> /// The external Url representing the entries of this collection /// </summary> public required string Url { get; set; } /// <summary> /// The date the Collection was created at. /// </summary> public required DateOnly CreatedAt { get; set; }}
public class Collection{ /// <summary> /// The UUID of this Collection /// </summary> public required string Id { get; set; } /// <summary> /// The external Url representing the entries of this collection /// </summary> public required string Url { get; set; } /// <summary> /// The date the Collection was created at. /// </summary> public required DateOnly CreatedAt { get; set; }}
However, when responding to requests, this is instead formatted as
request, but I'm having trouble figuring out how to properly parse the incoming
application/hal+json
application/hal+json
to my Model.
I've read online that Model Binding is probably the solution to this, but the vast majority of examples and explanations I could find were centered around Routes / Query parameters, not RequestBody formatting. The part I did find mentioned ValueProviders, but I couldn't find out how to obtain the JSON data from the body and store it as keys there.
Any suggestions are appreciated, as I'm rather new to MVC architecture and C# in general.