Can I have 2 post methods with different datatypes as below :-
[HttpPost]
public HttpResponseMessage Post([StringBody]string data)
{
// Logic
}
[HttpPost]
public HttpResponseMessage Post(Requirements objRequirement)
{
//Logic
}
I am getting below error in postman :-
<Error>
<Message>An error has occurred.</Message>
<ExceptionMessage>Multiple actions were found that match the request:
System.Net.Http.HttpResponseMessage Post(Newtonsoft.Json.Linq.JObject) on type ATL.Trebuchet.RestApi.Controllers.ValuesController
System.Net.Http.HttpResponseMessage Post(ATL.Trebuchet.RestApi.Models.Requirements) on type ATL.Trebuchet.RestApi.Controllers.ValuesController</ExceptionMessage>
<ExceptionType>System.InvalidOperationException</ExceptionType>
<StackTrace> at System.Web.Http.Controllers.ApiControllerActionSelector.ActionSelectorCacheItem.SelectAction(HttpControllerContext controllerContext)
at System.Web.Http.Controllers.ApiControllerActionSelector.SelectAction(HttpControllerContext controllerContext)
at System.Web.Http.ApiController.ExecuteAsync(HttpControllerContext controllerContext, CancellationToken cancellationToken)
at System.Web.Http.Dispatcher.HttpControllerDispatcher.SendAsyncInternal(HttpRequestMessage request, CancellationToken cancellationToken)
at System.Web.Http.Dispatcher.HttpControllerDispatcher.SendAsync(HttpRequestMessage request, CancellationToken cancellationToken)</StackTrace>
</Error>
Please help how can have same Post method with different type of parameters
I am sending data as Text (text/plain)
EDIT 1 :