I had created a API named FormsApi and method name CreateLead here is the code.when i try to run the code its showing page not found 404 error.Here is the code
[Microsoft.AspNetCore.Mvc.Route("FormsApi/[action]")]
public class FormsApiController : UmbracoApiController
{
Unable to Route the API Controller Method
I had created a API named FormsApi and method name CreateLead here is the code.when i try to run the code its showing page not found 404 error.Here is the code
[Microsoft.AspNetCore.Mvc.Route("FormsApi/[action]")] public class FormsApiController : UmbracoApiController {
}
Hi pavan
something caught my eye in your code sample, might be wrong, but should it be
Microsoft.AspNetCore.Mvc.FromBody
https://github.com/dotnet/aspnetcore/blob/29a9c90edf6dbd773296723e8f82605d0364d9f2/src/Mvc/Mvc.Core/src/FromBodyAttribute.cs#L13
rather than System.Web.Http.FromBody?
regards
Marc
If you want to use your own API's in an Umbraco site without doing custom routing, inherit from UmbracoApiController:
https://docs.umbraco.com/umbraco-cms/reference/routing/umbraco-api-controllers.
Also the 'FromBody' is not needed, because complex types are always read from the body. The 'FromBody' is only required if you want to force simple types (like string, guid etc) to be loaded from the body, because by default they are loaded from the querystring: https://learn.microsoft.com/en-us/aspnet/core/mvc/models/model-binding?view=aspnetcore-8.0#sources
is working on a reply...