Use case:
- External system wants to publish Platform Events to Salesforce.
- Salesforce wants to consume the Platform Events in a bulkified manner
The Platform Events doc offers this REST call:
/services/data/v42.0/sobjects/Low_Ink__e/
with POST body
{
"Printer_Model__c" : "XZO-5"
}
But this won't be bulkified. The incoming Apex trigger (or Process Builder) will receive events 1×1.
How to do this in a bulkified manner?
Best Answer
In V42.0, SFDC added a new REST composite collection resource that is bulkified and works with Platform Events!
/services/data/v42.0/composite/sobjects
I had a simple trigger that consumed this Platform Event. Examining the debug log after submitting the above through Workbench yielded:
Note the
allOrNone
property that allows for partial success.Note also that the running user is Automated Process, not the user you logged into Workbench with. As I did this in a fresh sandbox, I needed to be aware that the trigger needed to be recompiled.