web
You’re offline. This is a read only version of the page.
close
Skip to main content

Notifications

Announcements

No record found.

Community site session details

Community site session details

Session Id :
Customer experience | Sales, Customer Insights,...
Suggested Answer

Getting not supported error while open the attachments(which is created from web api) in case record

(0) ShareShare
ReportReport
Posted on by 1,000

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);
}
}
};

I have the same question (0)
  • Suggested answer
    a33ik Profile Picture
    84,331 Most Valuable Professional on at

    Hello,

    I believe the reason is documentbody of the file that you set:

    entity.documentbody = "Test Title";

    It should be Base64Encoded string and I don't think that word document content will be simple "Test Title".

  • Inogic Profile Picture
    682 on at

    Hi,

    When you are trying to create any attachment then you need to give the document body in base64 encoded string format to read the file.

     

    entity.isdocument = true;

    // First Convert your file to byte format and then convert in to base64Encoded String format

    // Here you need to give base64 encoded format.

    entity.documentbody = "<Provide your base64 encoded format of the document here>";

     

    Hope this helps.

     

    Thanks!

Under review

Thank you for your reply! To ensure a great experience for everyone, your content is awaiting approval by our Community Managers. Please check back later.

Helpful resources

Quick Links

Responsible AI policies

As AI tools become more common, we’re introducing a Responsible AI Use…

Neeraj Kumar – Community Spotlight

We are honored to recognize Neeraj Kumar as our Community Spotlight honoree for…

Leaderboard > Customer experience | Sales, Customer Insights, CRM

#1
Tom_Gioielli Profile Picture

Tom_Gioielli 170 Super User 2025 Season 2

#2
#ManoVerse Profile Picture

#ManoVerse 70

#3
Jimmy Passeti Profile Picture

Jimmy Passeti 50 Most Valuable Professional

Last 30 days Overall leaderboard

Product updates

Dynamics 365 release plans