Hi There, I have an application that communicates to AGOL's Portal API to carry out a few tasks. One of these tasks is to check the membership of a group.Here is a code snippet below.
function checkMembership() {
var restService = "https://www.arcgis.com/sharing/community/groups/" + groupId + "/users";
var restParameters = "?v=1&f=json&token=" + tokenInformation.token;
$.ajax({
"type":"POST",
"url":restService + restParameters,
"dataType":"json",
success:function (json) {
},
error:function (xhr, err) {
}
})
}
The error been thrown in the console is:XMLHttpRequest cannot load https://www.arcgis.com/sharing/community/groups/[GROUP ID]/users?v=1&f=json&token=[TOKEN] Origin http://localhost is not allowed by Access-Control-Allow-Origin.Now I know this is due to the lack of CORS support on that server and I can see this by the error message and in most cases it can be ignored, but this is stopping the function from being run.If I can the crafted URL and paste it into a browser, it executes fine. Any ideas on how one can query the Portal API without this happening?Thanks