- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report
Hello,
I'm trying to set up a basic web portal which displays data retrieved from my tenant. I can successfuly log in (using html forms I've set up myself), but using the token in subsequent requests does not seem to work! I'm trying to use jQuery.ajax() method -- I've also attempted the vanilla XMLHttpRequest functions, but I get similar errors.
function getUserData(token) { var url = "https://mytenant.autodeskplm360.net/api/rest/v1/users/current_user"; console.log(token); $.ajax({ url: url, method: "GET", headers: token, }).done(function(resp){ console.log(resp); }).fail(function(r){ console.log("failed"); }); } //token successfully received and parsed through earlier code: var auth = "Cookie: customer=MYTENANT;JSESSIONID=1726BD35893E3AC68DF544448A9FE438.web13" getUserData(auth);
Does anybody know what I'm doing wrong? I can't find any examples of successful http requests using javascript in the forums (besides this one ) but it does not cover the cookie-header part, which seems to be tripping up my code. See attached image for the error I receive.
I should note that instead adding the header as a key/value pair:
{"Cookie": token}
makes my browser console yell at me ( "Refused to set unsafe header 'Cookie'")
I'm stumped!
Solved! Go to Solution.