I have scenario in my application to call Acumatica endpoints by the client side script(JQUERY) , getting error of CORS policy like ‘origin been blocked by CORS policy: Response to preflight request doesn't pass access control check: Redirect is not allowed for a preflight request’, but I am able to call Acumatica token API, to get access token, I am sharing code below
--------------------------------Get access token----------------------------
function CallTokenAPI(){
$.ajax({
url : 'https:/{Acumatica Instance}/identity/connect/token',
type : 'POST',
contentType: 'application/x-www-form-urlencoded',
data : {
"grant_type": "password",
"username": "XXXXXXX",
"password": "XXXXXXX",
"scope": "api",
"client_id": "XXXXXX@Company"
"client_secret": "XXXXXXXXXX"
},
success : function(data){
localStorage.setItem('token',data.access_token);
console.log(data);
},
error : function(request,error){
console.log(request);
}
});
}
--------------------------------Get Stockitem----------------------------
function CallGetItemAPI(){
$.ajax({
url : 'https://{Acumatica Instance}/entity/Default/23.200.001/StockItem',
type : 'GET',
contentType: 'application/x-www-form-urlencoded',
headers: {
"Authorization": `bearer ${localStorage.getItem('token')}`,
},
success : function(data) {
console.log(data);
},
error : function(request,error){
console.log(request);
}
});
}
Please help me, as I am able to call Acumatica token API, to get access token, but not able to get stockitem by calling stockitem endpoint API
Thanks