-2

Scenario is

  1. Call the web service and get the response
  2. Update one object with response details in future
  3. after that call the another call out using one of the response value

And i am getting call out exception , will queueable apex with do the job?

3
  • 1
    Is this a distinct question from your previous one?
    – David Reed
    Jul 19 '19 at 0:50
  • there's no way you can do callouts after DML in the same Txn; you will need to do the second callout in a subsequent txn
    – cropredy
    Jul 19 '19 at 1:31
  • Actually, if you make a Visualforce Page with a controller and call getContentAsPDF you can do the DML in the controller code with no problems. Or you could a couple years ago. Jul 19 '19 at 6:41
1

Try to rearrange your steps:

1) Callout to the webService -> you'll get response.

2) Callout to another service with one of your response's values (as you have your response already).

3) Update object with response details in the same transaction, no need for future context.

OR

Another approach I can suggest:

1) Callout to the webService -> you'll get response.

2) Update object with response details in the same transaction.

3) Callout to another service with one of your response's values (as you have your response already) in the @future(callout=true) method, where the argument will be your response's value.

3
  • Got your point for step 2 , its a future method and i can not return the status of the second callout , any idea.
    – Edward
    Jul 19 '19 at 9:12
  • Then you should follow the first guidance and do not use async context at all. Jul 19 '19 at 9:54
  • I did that , perfectly placed everything and calling the update method as follow response= http.send(req) ; IAM_Authorization.updateCurrentConfiguration(token, expires_in, configID);
    – Edward
    Jul 19 '19 at 11:38

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.