Hi Team ,
I'm trying to create a attachment in case entity record. For this I'm using rest builder . The attachment is getting created against the case record but the problem is if I click and trying to open the attachment its showing "Not Supported" .
Request :
var entity = {};
entity.subject = "From API";
entity.isdocument = true;
entity.documentbody = "Test Title";
entity.mimetype = "application/vnd.openxmlformats-officedocument.wordprocessingml.document";
entity["objectid_incident@odata.bind"] = "/incidents(Guid here)";
entity.filename = "fromApi.docx";
var req = new XMLHttpRequest();
req.open("POST", Xrm.Page.context.getClientUrl() + "/api/data/v9.1/annotations", true);
req.setRequestHeader("OData-MaxVersion", "4.0");
req.setRequestHeader("OData-Version", "4.0");
req.setRequestHeader("Accept", "application/json");
req.setRequestHeader("Content-Type", "application/json; charset=utf-8");
req.onreadystatechange = function() {
if (this.readyState === 4) {
req.onreadystatechange = null;
if (this.status === 204) {
var uri = this.getResponseHeader("OData-EntityId");
var regExp = /\(([^)]+)\)/;
var matches = regExp.exec(uri);
var newEntityId = matches[1];
} else {
Xrm.Utility.alertDialog(this.statusText);
}
}
};