Hi I am trying to associate two types of records -- a conference and a market sector. I have created an N:N relationship between them and am using the CRM REST Builder to associate the two records given their ID #'s.
The code to create this relationship looks like:
var association = {'@odata.id': Xrm.Page.context.getClientUrl() + "/api/data/v8.0/ene_conferences(5B328BD3-24A1-E611-80F4-5065F38A4B81)"}; var req = new XMLHttpRequest(); req.open("POST", Xrm.Page.context.getClientUrl() + "/api/data/v8.0/ics_marketsectors(365303DE-077D-E511-8102-FC15B428ABA4)/ene_ene_conference_ics_marketsector/$ref", true); 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 { alert(this.statusText); } } }; req.send(JSON.stringify(association));
or see picture:
When I run this request, it just says "Bad Request" and I cannot seem to figure out why this is happening. I've double checked the ID's and they are correct.
Is my request impossible via this method? Any thoughts on what else I can test or do?
Thanks!