Angular get request 415 error

Hi guys I'm trying to make a get request with angular and I don't seem to be able to. It fly's in both jquery and postman. But I always get a 415 unsupported media type when I make a get request in angular. Please help me.

Here's my code in angular and jquery.

            var deferred = $q.defer();
        $http({
            method: 'GET', 
            url: url,
            headers : {'Content-Type':'application/json'}
        }).
        success(function(data, status, headers, config) {
            deferred.resolve(data);
        }).
        error(function(data, status, headers, config) {
            deferred.reject(data.ExceptionMessage);
        });
        return deferred.promise;

//--------------------------------------------------

        $.ajax({
            type: 'GET',
            url: url,
            contentType: 'application/json'
        })
        .done(function( data ) {
            console.log(data);
        })
        .fail(function( err ) {
            console.log(err);
        });

And here is the error

GET https://oc4showcaseservice.azurewebsites.net/api/getdocumentlist/?localList=false&regionId=&searchTerm=&tagFilters= 415 (Unsupported Media Type)(anonymous function) @ angular.min.js:93r @ angular.min.js:89g @ angular.min.js:86(anonymous function) @ angular.min.js:119r.$eval @ angular.min.js:133r.$digest @ angular.min.js:130r.$apply @ angular.min.js:134g @ angular.min.js:87T @ angular.min.js:92w.onload @ angular.min.js:93 (index):1 XMLHttpRequest cannot load https://oc4showcaseservice.azurewebsites.net/api/tag?$filter=tagType_Id%20eq%20%27645685D7-01C5-414B-BF15-7E37A366EDC6%27. No 'Access-Control-Allow-Origin' header is present on the requested resource. Origin 'http://localhost:3000' is therefore not allowed access.

链接地址: http://www.djcxy.com/p/13606.html

上一篇: 角度js自定义服务/工厂无法注入控制器/配置

下一篇: 角度获取请求415错误