I have login method:
[HttpPost("login")]
public ResponseBody<UserContext> Login([FromBody] RequestBody<Operator> userCredentials)
{}
RequestBody
have T Data
field.
is it possible to convert this method to be able to handle both JSON and BSON?
Add BSON support to your API, this artcile should help. And based on request type API can supprort both JSON and BSON.
From article:
public static class WebApiConfig
{
public static void Register(HttpConfiguration config)
{
config.Formatters.Add(new BsonMediaTypeFormatter());
// Other Web API configuration not shown...
}
}
Now if the client requests "application/bson", Web API will use the BSON formatter.