I am trying to add users to a team using Web API but was thrown with below error.
I tried reversing entities as mentioned in other posts but of no avail. Same error pops up.

Please see my code below. Any help is very much appreciated. Also , please let me know why this error pops up.
for (var j = 0; j < teamids.length; j++) {
var AssociationParameter = {"@odata.id": "crmurl/.../teams(" + teamids[j] + ")"};
var url = "crmurl/.../systemusers(" + id + ")/" + AssociationName + "/$ref";
var req = new XMLHttpRequest();
req.open("POST", url, false);
req.setRequestHeader("Accept", "application/json");
req.setRequestHeader("Content-Type", "application/json; charset=utf-8");
req.setRequestHeader("OData-MaxVersion", "4.0");
req.setRequestHeader("OData-Version", "4.0");
req.onreadystatechange = function () {
if (this.readyState === 4) {
req.onreadystatechange = null;
if (this.status === 204 || this.status === 1223) {
alert("role associated - roleid");
}
else {
alert(JSON.parse(this.response).error.message);
}
}
}
};
req.send(JSON.stringify(AssociationParameter));
}
*This post is locked for comments
I have the same question (0)