I am getting this error when i upgrade the api version from 34 to 45 ."You have already made DML statements. You cannot make callouts after making DML statements."can anyone suggest me some ideas .
May I request you please confirm, After your DML statement are you making any callout?
We cannot perform callout after DML statement because callout will take time to return and salesforce does not wait to write or update records in the database.
The DML operation performs a transaction it returns the data after performing transaction completely so if you perform callout in the middle it may affect the result. It’s true that you cannot make callouts with pending transactions in the request context. Also, it’s not possible to do an explicit commit. So your only way out is to make the callout in a separate context.
Sorry for this issue you are facing.
May I request you please confirm, After your DML statement are you making any callout?
We cannot perform callout after DML statement because callout will take time to return and salesforce does not wait to write or update records in the database.
The DML operation performs a transaction it returns the data after performing transaction completely so if you perform callout in the middle it may affect the result. It’s true that you cannot make callouts with pending transactions in the request context. Also, it’s not possible to do an explicit commit. So your only way out is to make the callout in a separate context.
Thanks,
Nagendra