function readOnly(count){ }
Starting November 20, the site will be set to read-only. On December 4, 2023,
forum discussions will move to the Trailblazer Community.
+ Start a Discussion
Teddy OstrowskiTeddy Ostrowski 

Create Opportunity Note using REST API

I'm attempting to create a note for an opportunity via the REST API.  I'm finding several examples for the SOAP API, but nothing that works using REST.  Using this API I am able to create a note, but can find no way to associate it with an opportunity ID:

https://developer.salesforce.com/docs/api-explorer/sobject/Note

Any help would be greatly appreciated.
Best Answer chosen by Teddy Ostrowski
Abdul KhatriAbdul Khatri
OK the Notes you are referring is the enhance Notes. Please check the article below for details
https://douglascayers.com/2017/05/08/convert-notes-to-enhanced-notes/

I doubt there is any REST API for the same as getting the Content Notes is not straight forward as it required to be linked through a different object. Here is the link detailing this out
https://salesforce.stackexchange.com/questions/137227/creation-order-of-contentnote-and-contentdocument/137433

Please let me know what exactly is your goal so that work on accrodingly.

All Answers

Abdul KhatriAbdul Khatri
Is this what you are looking for
 
HttpRequest req = new HttpRequest();
req.setHeader('Authorization', 'Bearer ' + UserInfo.getSessionID());
req.setHeader('Content-Type', 'application/json');
req.setEndpoint(URL.getOrgDomainUrl().toExternalForm() + '/services/data/v44.0/sobjects/Note');
req.setBody('{"Body" : "Test2","ParentId" : "0066100000KeDQZAA3","Title" : "Test2"}');
req.setMethod('POST');
Http http = new Http();
HttpResponse res = http.send(req);
system.debug(res);

 
Teddy OstrowskiTeddy Ostrowski
Thank you for the response.  That code does indeed work (receive HTTP 201 and a note ID in JSON response), however I do not see the note attached to the Opportunity.  I don't see the note at all in Salesforce for that matter.
Abdul KhatriAbdul Khatri
Did you put your Opportunity ID in the ParentId in JSON?
Teddy OstrowskiTeddy Ostrowski
I did, but it still doesn't show when I view the Opportunity.
Abdul KhatriAbdul Khatri
Are you using Classic or Lightning?
Teddy OstrowskiTeddy Ostrowski
Lightning
Abdul KhatriAbdul Khatri
Do note added on the Page? Please edit the page and add it
Teddy OstrowskiTeddy Ostrowski
I'm sorry, I don't follow?
Abdul KhatriAbdul Khatri
If you are an Administrator, then upper right corner you will see grey wheel like setting icon, click that and click Edit Page. Then in the left panel you will see Related List icon, add that anywhere on the page and select Notes and Attachment
Abdul KhatriAbdul Khatri
Do the above while on the opportunity?
Teddy OstrowskiTeddy Ostrowski
I already have the "Related List Quick Links" enabled, which does not show the new note:
User-added image
Abdul KhatriAbdul Khatri
Have you navigated to the Id you get in the response. I am not near my computer but I was able to see notes in my case.
Abdul KhatriAbdul Khatri
Mine are you showing up. Also mine says Notes And Attachments which I guess the old way of showing Attachments and in new one Notes is separated but I still see them together in mine Org.
User-added image
Abdul KhatriAbdul Khatri
OK the Notes you are referring is the enhance Notes. Please check the article below for details
https://douglascayers.com/2017/05/08/convert-notes-to-enhanced-notes/

I doubt there is any REST API for the same as getting the Content Notes is not straight forward as it required to be linked through a different object. Here is the link detailing this out
https://salesforce.stackexchange.com/questions/137227/creation-order-of-contentnote-and-contentdocument/137433

Please let me know what exactly is your goal so that work on accrodingly.
This was selected as the best answer