You need to sign in to do that
Don't have an account?
King Koo
transaction control with REST API - does it exist?
Hi there
It may be a dumb question but is there any transaction control capability with REST API?
I have SAP sending data over to my Salesforce instance over some middleware, calling REST API. I don't have any web services exposed or anything. The middleware basically just simply pumps data from SAP into Salesforce calling REST API (/composite/batch resource).
I'm wondering what if the batch is sending me 20 records (say one account followed by 5 contacts, 5 opportunities and 9 orders). If any of the record fails, is there a way for the REST API to rollback this set of 20 records?
Is there also a place in Salesforce that I can view the REST API log?
Thanks
King
It may be a dumb question but is there any transaction control capability with REST API?
I have SAP sending data over to my Salesforce instance over some middleware, calling REST API. I don't have any web services exposed or anything. The middleware basically just simply pumps data from SAP into Salesforce calling REST API (/composite/batch resource).
I'm wondering what if the batch is sending me 20 records (say one account followed by 5 contacts, 5 opportunities and 9 orders). If any of the record fails, is there a way for the REST API to rollback this set of 20 records?
Is there also a place in Salesforce that I can view the REST API log?
Thanks
King
Another alternative is to create your own Apex method to do the DML operations and expose it via the REST API. With the standard Apex transaction control it will roll back for you. Or you can use the explicity Database methods to handle errors.
You can view the REST API log using the Event Monitoring API (https://developer.salesforce.com/docs/atlas.en-us.api_rest.meta/api_rest/using_resources_event_log_files.htm). REST API calls will ofter show up in the Debug log as well if there is an active Trace Flag.
Thanks for your reply.
How can I combine these two concept though? Let's say using the example I have above, I have 20 recrds, for the one accout, but I have over 2000 accounts. (That's why I was using /composite/batch. I don't think it would make sense to use /composite/tree/Account 2000 times, once for each account?
As for event monitoring, is that the one through Setup -> Monitor -> Logs -> Event Monitoring Setup? That one doesn't have any frontend interface so I have to use REST API to generate log right?
I was trying to use debug log but I don't understand how. Let's say if I'm just trying to post to account with (from workbench for example with REST)
what exactly do I have to do to see whether the insert is successful or not through the debug log?
I set the trace flag to FINEST for everything. I noticed if I have some validation rules or workflows then I can see some log. But what if the object has none of that, would I be able to see from the debug log that an attempt was made to insert a record with the above field values, and the attempt was successful, or not; and in the case of latter, that I be provided an error message?
Thanks
King
If there is a failure/problem you will be sent back a corresponding error.
I wasn't able to see any DML_BEGIN and DML_END - I did set Database to Finest. But the only things that it went through were the validation rules, workflow rules and my duplicate rules. I was hoping to find something like DML_BEGIN too.
Any advice?
Thanks
I dug a little deeper, it looks like unless I issue those DML statements like insert, update, upsert, delete, there won't be any DML_BEGIN or DML_END in the log.
These inserts are done via REST API, so no DML statements, looks like.
The integration developer is hoping to find some way for Salesforce to spit out some logs every time when he sends records over REST API. I'm still not sure if I can use the debug log or not.....
Thanks
King