AngularJS HTTP 415

0

I'm having trouble making a GET request, getting error 415 (Unsupported Media Type).

Although he has already set the headers he does not seem to respect them.

Does anyone have any suggestions on what to do to solve the problem? Remembering I'm new to AngularJS

$http.get('https://minhaurl.com.br/api/v1/tasks', 
            {
                headers: { 
                    'Accept': 'application/json; charset=utf-8',
                    'Content-Type' : 'application/json; charset=utf-8'
                }
            }
        );

    
asked by anonymous 16.10.2016 / 16:22

2 answers

0
Well, after a lot of searching I found a better 'gambiarra' ... at the time of setting the options of the HTTP method GET you must pass blank data, it will automatically change the content-type to application / json utf8

More like this:

 $http({
   method: 'GET',
   data: '',
   url: 'https://minhaurl.com.br/api/v1/tasks'
});
    
23.10.2016 / 04:47
0

Try this:

 $http({
       method: 'GET', 
       url: 'https://minhaurl.com.br/api/v1/tasks',
       headers: {
        'Content-Type' : 'application/json' 
       }
    });
    
16.10.2016 / 22:11