• Manoj Kumar 696
  • 0 Points
  • Member since 2019

  • Chatter
  • 0
    Best Answers
  • 0
    Likes Received
  • 0
    Likes Given
  • 0
  • 2
My VBA code as below has been working fine for long time, but recently it always get response = "". But I still can get authentication token as before. 
Dim objRequest As Object
    Dim fullUrl As String
    Dim blnAsync As Boolean
    Dim strResponse As String
    Set objRequest = CreateObject("MSXML2.XMLHTTP")
    fullUrl = Query_Data_Url_Production & query
    blnAsync = True
    With objRequest
        .Open "GET", fullUrl, blnAsync
        .SetRequestHeader "Authorization", "Bearer " & token
        'spin wheels whilst waiting for response
        While objRequest.readyState <> 4
        strResponse = .ResponseText
    End With
I also tried with curl and the token I obtain from salesforce api. 
User-added imageand response is empty, too.
Please do me a favour.
  • November 08, 2019
  • Like
  • 0

Hi all,

We need to implement the following pattern at my org:
  • callout to external data source
  • if that callout takes too long (according to some configurable threshold), log an error (ie do some DML)
  • if that callout timed out on the remote server, try it again
Recognizing the potential for the dreaded "You have uncommitted work pending. Please commit or rollback before calling out." error, I put the error logging code in a future method, thus isolating the DML from the callouts. However, the error is still being thrown. I reduced the issue down to this pattern:
public static void foo() {
    Http http = new Http();
    HttpRequest req = new Httprequest();
    req.setEndpoint('https://test.salesforce.com'); //whatever endpoint
    http.send(req); //works fine
    http.send(req); //throws calloutexception

@future public static void bar() {

Am I correct to assume that calling a future method counts as a DML operation? Is there any documentation I'm missing somewhere?