I have an asynchronous task set up in a C# controller like so that has been simplified here:
namespace MyApp.Api {
public class TimeAllocationController : BaseApiController
{
[Route("api/timeallocation")]
[HttpPost]
public async Task<ActivityValidationResult> Post(string id)
{
//logic here...
}
Ideally I'd like to pass the whole payload in JQuery using the $.post() method, but I keep getting a 405 method not allowed
if
I try to pass in C#'s Post()
string Id within the payload. I can only pass it in like so:
$.post('/api/timeallocation/' + categoryId...
I cannot pass it in like so:
$.post('/api/timeallocation?id=' + categoryId...
I'd like to do neither of the above, just set up a payload
variable in the JS file with the id and all the other required attributes, and call $.post()
on that.
As for other possible reasons for the 405 error, I have verified that it is not due to authentication reasons.
Is there something I am overlooking here?