0

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>"}
MarcusM.
  • 86
  • 6
  • 1
    The Content-Type = application/x-www-form-urlencoded indicates that the data is sent as value pair (Form). May be try the Content-Type = text/xml for application/xml ? – thanyaj Jul 01 '15 at 22:24
  • Thanks for the response but neither of those suggestions worked. I feel like I am doing something syntactically incorrect because it doesn't seem to be even making the call to the serve just jumping straight to the error block. – MarcusM. Jul 02 '15 at 12:55
  • 1
    possible duplicate of [HTTP Status 0 from AngularJS Get for JSON](http://stackoverflow.com/questions/17929804/http-status-0-from-angularjs-get-for-json) – Paul Sweatte Aug 13 '15 at 14:55

0 Answers0