3

Anyone knows how to create an "annotation" using CRM Web API. I can create other objects such as account and contacts but annotation attachment is a no go. Seems like my object is missing something.

    JObject notes = null;
            notes = new JObject();

            notes["isdocument"] = true;
            notes["objecttypecode"] = "mfr_ownermlslistingwaiver";
            notes["ownerid@odata.bind"] = "/systemusers(E94126AC-64FB-E211-9BED-005056920E6D)";
            notes["owneridtype"] = 8;
            notes["documentbody"] = "/9j/4VmjRXhpZgAASUkqAAgAAAANAAABBAABAAAAIBAAAAEBB...";
            notes["minetype"] = "image/jpeg";
            notes["filename"] ="2213 Scrub Jay Rd.jpg";
            notes["objectid@odata.bind"] = "/mfr_ownermlslistingwaivers(137C660B-ADAA-E711-80CD-005056927DF7)"; 
HttpResponseMessage createResponse =
              await httpClient.SendAsJsonAsync(HttpMethod.Post, "annotations", notes);
zAnthony
  • 332
  • 4
  • 17
  • are you receiving an error of any kind off of the post? Maybe try sending it synchronously to see what happens. Also, have you consulted this example? https://msdn.microsoft.com/en-us/library/gg328429.aspx – Marshall Tigerus Oct 10 '17 at 20:20
  • Possible duplicate of [Create annotation to a contact entity in Microsoft Dynamics CRM by API](https://stackoverflow.com/questions/32761311/create-annotation-to-a-contact-entity-in-microsoft-dynamics-crm-by-api) – Pawel Gradecki Oct 11 '17 at 20:50

1 Answers1

3

You have couple of issues in code.
1. Typo in mimetype
2. Incorrect Single valued navigation property - objectid@odata.bind and it should be objectid_[entity]@odata.bind

Necessary properties should look like below:

note["notetext"] = "Invoice Report Attached"
note["subject"] = "Invoice";
note["filename"] = "Invoice.pdf";
note["mimetype"] = "application/pdf";
note["objectid_account@odata.bind"] = "/accounts(C5DDA727-B375-E611-80C8-00155D00083F)";
note["documentbody"] = [base64String]; 

Reference & similar thread