Optional Parameters in Web Api Attribute Routing
I want to handle POST of the following API-Call: /v1/location/deviceid/appid Additional Parameter are coming from the Post-Body. This all works fine for me. Now I wnat to extend my code by allowing "deviceid" and/or "appid" and/or BodyData to be null: /v1/location/deviceid /v1/location/appid /v1/location/ These 3 URLs should responded by the same route. My first approach (BodyData required): [Route("v1/location/{deviceid}/{appid}", Name = "AddNewLocation")] public location_fromuser Post(string deviceid = null, string appid = null, [FromBody] location_fromuser BodyData) { return repository