My requirement is to create an association between 2 entity records where there is an N:N relationship between those 2 entities. I built the query with the REST builder. But when I execute it gives the error “Bad Request”. When I examined the response using F12 developer tools the details error is like this:
“Invalid role specified for entity 'new_contract'in relationship 'new_cancellationreason_contract.Referencing”.
My relationship name, entity names and GUIDs are double checked and correct. Any idea what this error is??
This is my query which was generated by the REST builder:
var association = { "@odata.id": Xrm.Page.context.getClientUrl() + "/api/data/v8.2/new_cancellationreasons(6abb5393-b53e-e711-80d4-005056b44566)" }; var req = new XMLHttpRequest(); req.open("POST", Xrm.Page.context.getClientUrl() + "/api/data/v8.2/new_contracts(104A85B0-6DA9-E611-B581-005056B44BD9)/new_cancellationreason_contract/$ref", 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) { //Success - No Return Data - Do Something } else { Xrm.Utility.alertDialog(this.statusText); } } }; req.send(JSON.stringify(association));
*This post is locked for comments