So I am trying to close a case via Web API using the CloseIncident function. I have setup the code below. For some reason, the api is responding with error 415:
"The request contains an entity body but no Content-Type header. The inferred media type 'application/octet-stream' is not supported for this resource."
I have tried also tried the code on a CRM 2016 server with december update and still got the same error. Am I missing something?
Code:
var closeIncidentPayload = JSON.stringify({ "Status": status, "IncidentResolution": { "incidentid@odata.bind": "/incidents(" + caseid.replace(/[{}]/g, "") + ")", "subject": "Put Your Resolve Subject Here", "timespent": 0, "description": "Additional Description Here" } }); var xhr = new XMLHttpRequest(); xhr.open("POST", "/api/data/v9.0/CloseIncident"); xhr.setRequestHeader("Accept", "application/json; charset=utf-8;"); xhr.setRequestHeader("Content-Type", "application/json; charset=utf-8;"); xhr.setRequestHeader("OData-MaxVersion", "4.0"); xhr.setRequestHeader("OData-Version", "4.0"); xhr.onreadystatechange = function () { if (this.readyState === 4) { this.onreadystatechange = null; switch (status) { case 200: case 201: case 204: break; default: console.error("Failed CloseIncident Request"); break; } } }; xhr.send(closeIncidentPayload);
*This post is locked for comments