1
I have a POST method in Webapi, and this defined the Routeprefix of the Api, 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 this way: http://grupo.ddns.net/GRUPO/api/v1/crm/registros
Dominio: http://grupo.ddns.net
Directory inside the server (where code is published): GRUPO/
Routeprefix (from the API): api/v1/crm/
Route (POST method): registros
The problem is this:
when I put this application on the net, it shows a path error not found (404) in this URI above.
In view of this server structure with directory, and the API Routes, how should I set up the URI to work the registration on the net? Or, I must do something different to work better?
Remembering that the Server stays in the company and as seen in the domain above, has no fixed IP.