So I am trying to hit an end point on our server in AngularJS. The endpoint is expecting XML data. However when I make the request it seems like the endpoint is never being hit. The request goes directly to the error catch block with the status code of 0 and no headers and no data. Anyone see what I am doing wrong here? Thanks!
.factory('authService', function ($http, $q) {
return {
login: function () {
var deferred = $q.defer();
var req = {
method: 'PUT',
url: serverURL + '/authentication',
headers: {
"Content-Type": 'application/x-www-form-urlencoded',
'Accept': 'application/json',
'Authorization': 'Basic sdasdasda'
},
data: '<NAME xmlns="schemas">' +
'<SignInRequest>' +
'<UserName>UserName</UserName>' +
'<PWD>Password</PWD>' +
'<DeviceID>3242342342</DeviceID>' +
'<DeviceToken></DeviceToken>' +
'<OSVersion>8.0</OSVersion>' +
'<OSType>iOS</OSType>' +
'</SignInRequest>' +
'</NAME>'
};
$http(req)
.success(function (data, status, headers, config) {
deferred.resolve(data.StatusId);
}).error(function (data, status, headers, config) {
deferred.reject(status);
});
return deferred.promise;
}
}
Here is the config returned from the error (Data removed for security i.e. URL and Schema):
{"method":"PUT","transformRequest":[null],"transformResponse":[null],
"url":"url",
"headers":{"Content-Type":"application/x-www-form-urlencoded","Accept":"application/json","Authorization":"Basic asdasdasd"},
"data":"<NAME xmlns=schems><SignInRequest><UserName>username</UserName><PWD>password</PWD><DeviceID>dasdas</DeviceID><DeviceToken></DeviceToken><OSVersion>8.0</OSVersion><OSType>iOS</OSType></SignInRequest></NAME>"}