Hi Andrew,
Here is the complete code.
var parameters = {
"Target": {
"new_employeeid" : employeeid,
"@odata.type" : "Microsoft.Dynamics.CRM.new_employee"
},
"PrincipalAccess": {
"Principal" : {
"teamid" : teamid,
"@odata.type" : "Microsoft.Dynamics.CRM.team"
},
"AccessMask" : "ReadAccess"
}
}
var uri = window.parent.Xrm.Page.context.getClientUrl() + API.strWEBAPIPATH + "/GrantAccess";
var request = new XMLHttpRequest();
request.open("POST", encodeURI(uri), true);
request.setRequestHeader("OData-MaxVersion", "4.0");
request.setRequestHeader("OData-Version", "4.0");
request.setRequestHeader("Accept", "application/json");
request.setRequestHeader("Content-Type", "application/json; charset=utf-8");
request.setRequestHeader("Prefer", "odata.include-annotations=OData.Community.Display.V1.FormattedValue");
let ready = true;
request.onreadystatechange = function () {
if (this.readyState === 4) {
request.onreadystatechange = null;
if (this.status === 200) {
debugger;
// success - do something
}
if(this.status === 204) {
debugger;
// success - do something
}
else {
ready = false;
}
}
else {
ready = false;
}
};
if (ready) request.send(JSON.stringify(parameters));
When I send a request with "/GrantAccess" appended to the end of the URI everything works as expected and the team gets access to the employee, however when I append "/RevokeAccess" I receive an error that there is no HTTP resource matching the request URI.
Thank you,
Scott