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
Juan SpagnoliJuan Spagnoli 

System.CalloutException without any DML operation

Hi guys, I'm stuck here with "System.CalloutException: You have uncommitted work pending. Please commit or rollback before calling out".

 

I know that you cannot do a DML operation before making a callout, but in my case, I'm not doing any operation!! It seems that the problem is when I call to a future method before the callout... I have to do an update that it doesn't need to be synchronized with my normal flow, and that it's why I'm using a @future method. 

 

Did anyone have to face something like this?

 

Thanks!

ShamilShamil

Check the API version for your Apex classes - make sure you're using the latest.

If that doesn't help, can you post your code here?

Juan SpagnoliJuan Spagnoli

Mmmm.. The API version is 19.0. Anyway I'm approaching an alternative solution because I'm thinking that there is only 200 future calls per user, and I think that we'll have few users per org, so maybe using @future is not the best workaround for this requirement.

 

Thanks! 

ShamilShamil

Not sure if your scenario involves a VF page, if so - people have been discussing a workaround here

Juan SpagnoliJuan Spagnoli

Well... If I were using a VF then It would be much easy, but I'm using an Apex Rest API method. Maybe whit a VF you can save the record in a method called by the "action" parameter of "apex:page" tag, or something like that.