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
Prasad RuwanpathiranaPrasad Ruwanpathirana 

how make call for a rest service from future method?

I'm going to call for a rest service to the same salesforce instance to make a dml operation from a future method. In the future method i'm calling to a another webservice and then after i'm going to make that dml operation through the rest service. But i'm getting the "caused by: System.CalloutException: You have uncommitted work pending. Please commit or rollback before calling out" error. Is there any way to do that dml operation in the from the future method?
Navin SoniNavin Soni
@future public static void futuredebug(object x) {
         system.debug(x);
}
public static void currentdebug(object x) {
         system.debug(x);
}
// synchronous example:
@istest public static void testsync() {
test.starttest();
currentdebug(1);
currentdebug(2);
test.stoptest(); // OUTPUT is 1, 2
}
@isTest public static void testasync() {
test.starttest();
futuredebug(1);
currentdebug(2);
test.stoptest(); // OUTPUT is 2, 1
}