❔ WEBAPI [FromBody] Json with optional elements
I am building a .net Wep API application where I will be receiving requests where all of the data is in the JSON body. I understand this is not the preferred way to do this but this is how I have to do it for this application. I will receive a post from my frontend which essentially looks like this
My code is able to process this provided both startTimestamp and endTimestamp are occupied. However as they are optional attributes they will sometimes be absent from requests and in those cases I receive an error
I would like to be able to make these field not required but I am uncertain how.
My method which receives the request starts like this
My code is able to process this provided both startTimestamp and endTimestamp are occupied. However as they are optional attributes they will sometimes be absent from requests and in those cases I receive an error
I would like to be able to make these field not required but I am uncertain how.
My method which receives the request starts like this