我的补救措施小组告诉我,在调用带有查询参数的API时出现了“无法解析授权标头”错误
var yhttp = new XMLHttpRequest();
var phonedata=":People?q=%27Phone%20Number%20Business%27%20%3D%20%22%2B12017148030%22&fields=userid";
yhttp.open('GET', 'https://remproditsm.broadridge.net/api/arsys/v1/entry/CTM:People?q=%27Phone%20Number%20Business%27%20%3D%20%22%2B12017148030%22&fields=ciscofinesse');
yhttp.setRequestHeader('Authorization', 'Bearer' + response);
yhttp.setRequestHeader('Content-Type', 'application/json');
yhttp.send();
尝试了AR-JWT而不是Bearer,尝试了application / json标头,但没有,我不相信我是否应该在标头中传递它,但是补救团队建议我传递它。此外,这在Postman中也能正常工作。
答案 0 :(得分:0)
答案 1 :(得分:0)
好吧,我发现了问题,默认情况下,AJAx请求是异步的,正在使用响应中的变量作为令牌,并且当它到达第二个GET API请求时,res变量中没有任何内容,因此我将其转换为我的第一个令牌请求同步API
xhttp.open('POST','url',false);
xhttp.setRequestHeader('authString', 'authentication string');
xhttp.setRequestHeader('Content-Type', 'application/x-www-form-urlencoded');
xhttp.send(data);
res= xhttp.responseText;
document.write(res);
答案 2 :(得分:0)
是的,您需要“ AR-JWT {token}”作为授权标头值。该令牌应在登录调用之后存储,并用于随后的每个REST操作。 https://docs.bmc.com/docs/ars2008/examples-of-using-the-rest-api-to-get-update-and-delete-an-entry-from-a-form-929631054.html