Ajax / JSON server responded with status 415 (Unsupported Media Type)

The current project I'm working on requires me to talk to the Windows Live API. I am using an AJAX request to get a JSON object with user data. As always I get this error: Failed to load resource: server responded with status 415 (Unsupported media type)

My first idea was to add "& callback =?" url. But then I get the message "Uncaught SyntaxError: Unexpected token:" in the JSON response.

I was looking for how I can fix the errors. But no working solution was found for both errors. Upstairs if I'm completely unsure what error I should try to solve (status 415 or unexpected token). Anything that points me in the right direction would be greatly appreciated!

$.ajax({
        url: "https://apis.live.net/v5.0/me?access_token=" + localStorage.getItem('Live_token'),
        dataType: 'json',
        type : 'GET',
        contentType: "application/json;",
        async: false,
        success : function(data) {
            var id = data.id,
            fname = data.last_name,
            email = data.emails.preferred;//TODO preferred or account?
            alert(id + '|' + fname + '|' + email);
            localStorage.setItem('Live_verifier', id + '|' + fname + '|' + email);
        },
        error : function(data) {
            localStorage.removeItem('Live_token');
        }
    });

      

early

+3


source to share


1 answer


Have you tried to install

dataType: 'jsonp',

      



and "&callback=?"

in the url? You are calling a server on a different domain, so you have to set jsonp

likedataType

+2


source







All Articles