Web Api endpoints used in external javascript application throw 401 error despite of passing credentials in header in JavaScript XmlHttpRequest.
The code used was similar to below, which is throwing 401 error in browser.
How to authenticate dynamically to render content in front end javascript application, which is exposed via Appian Web Api.
$.ajax({ xhrFields: { withCredentials: true }, headers: { 'Authorization': 'Basic ' + btoa('myuser:mypswd') }, url: "https://xxxx.appiancloud.com/api/GetImage/1234" });
Discussion posts and replies are publicly visible
Tried the above snippet and it does not work. instead it says network error. Also tried to pass the credentials inside Open() without any headers and it throwed Access Error as shown below. Any advice please?
var xhr = new XMLHttpRequest();xhr.open("GET", "https..........", false,"usnmae","pwd");xhr.withCredentials = true;
xht.send();
Error:
InvalidAccessError: InvalidAccessError