I have a POST method in the WebAPI, and this is the Api RoutePrefix, the Route of the POST method and Cors is enabled.
[RoutePrefix("api/v1/crm")]
[EnableCors(origins: "*", headers: "*", methods: "*")]
public class EmpresaParticipanteController : ApiController
{
private SigCodeFirst db = new SigCodeFirst();
[HttpPost]
[Route("registros")]
public HttpResponseMessage PostRegistro(EmpresaParticipante empresaParticipante)
{
if (empresaParticipante == null)
return Request.CreateResponse(HttpStatusCode.BadRequest);
try
{
db.EmpresaParticipante.Add(empresaParticipante);
db.SaveChanges();
var resultado = empresaParticipante;
return Request.CreateResponse(HttpStatusCode.Created, resultado);
}
catch (System.Exception)
{
return Request.CreateResponse(HttpStatusCode.InternalServerError, "Falha ao incluir registro.");
}
}
}
In AngularJs, the script is as follows:
var crmApp = angular.module("Crm", []);
crmApp.controller("CrmCtrl", function ($scope, $http) {
$scope.adicionarRegistro = function (empresaParticipante) {
$http.post("http://grupo.ddns.net/GRUPO/api/v1/crm/registros", empresaParticipante).success(function (data) {
delete $scope.empresaParticipante;
$scope.novoCrmForm.$setPristine();
console.log(empresaParticipante);
carregarRegistros();
});
};
});
In the URI it looks like this: link
Domain: http://grupo.ddns.net
Directory inside server (where code is published): GRUPO/
RoutePrefix (API): api/v1/crm/
Route (POST method): registros
The problem is:
When I put this application on the net, it has a path error not found (404) in this URI above.
Given this structure of the directory server, and the API Routes, how should I mount the URI to work on the net? Or, should I do something different to work better?
Remembering that the server is in the company and as seen in the domain above, it has no fixed IP.