Previously I used the following type of headers in my function to make the request from the application:
Error
OPTIONS http://API_URL 405 (Method Not Allowed)
XMLHttpRequest cannot load http://API_URL. Response to preflight request doesn't pass access control check: No 'Access-Control-Allow-Origin' header is present on the requested resource. Origin 'http://192.168.1.9:8100' is therefore not allowed access. The response had HTTP status code 405.
Data Login
datos = {
Usuario: $scope.usuariotxt,
Password: $scope.passwordtxt
};
'Content-Type': 'application/x-www-form-urlencoded'
function
function Autenticacion(datos) {
var url = 'http://API_URL';
return $http.post(url, $httpParamSerializer(datos), {
headers: {
'Content-Type': 'application/x-www-form-urlencoded'
}
});
};
Now the content-type must be different from how you submitted the request in advance
'Content-Type': 'application/json'
function Autenticacion(datos) {
//var url = 'API_URL';
return $http.post(url, $httpParamSerializer(datos), {
headers: {
'Content-Type': 'application/json'
}
});
};
But using the ARC tool, the request works perfectly
The server is in Azure, this the information
Cache-Control: no-cache
Pragma: no-cache
Content-Length: 270
Content-Type: application/json; charset=utf-8
Expires: -1
Server: Microsoft-IIS/8.0
X-Aspnet-Version: 4.0.30319
X-Powered-By: ASP.NET
Set-Cookie: ARRAffinity=0a3517ba6ed8bb14ffe517099672a3eb4ea3c4b710ad8c6e0edaa70c2d244335;Path=/;Domain=apipedroupc20170125045931.azurewebsites.net
Date: Tue, 28 Feb 2017 20:53:09 GMT