title: System.CalloutException: Callout loop not allowed: Salesforce mobile SDK for iOS
body: <p>I am facing 'callout loop not allowed' issue while making a Apex REST webservice call from mobile app (Hybrid remote app developed using salesforce mobile SDK for iOS ) which in turn makes a callout to external webservice.</p>
  
  <p>This use case is about making a call to Authorise.net for payment processing. </p>
  
  <p>User->login->credit card details -> restful apex call - forceTk -> http callout to payment(within restful apex method)->update user with result</p>
  
  <p>Here is the code</p>
  
  <p><strong>Authentication:</strong></p>
  
  <pre><code>var forceTKClient;
  
  cordova.require("salesforce/plugin/oauth").authenticate(functionSuccessCallBack, functionErrorCallBack);
  
  function functionSuccessCallBack (creds) {
  
  var apiVersion = "v28.0";
  forceTKClient = new forcetk.Client(creds.clientId, creds.loginUrl, null, cordova.require("salesforce/plugin/oauth").forcetkRefresh);
  forceTKClient.setSessionToken(creds.accessToken, apiVersion , creds.instanceUrl);
  forceTKClient.setRefreshToken(creds.refreshToken);
  forceTKClient.setUserAgentString(creds.userAgent);
  }
  </code></pre>
  
  <p><strong>REST webservice</strong></p>
  
  <pre><code>/*************************************************************************
  * HttpPost method
  **************************************************************************/
  @HttpPost
  global static REST_ProcessOrder_V1.ProcessOrderResponse doPost
               (REST_ProcessOrder_V1.ProcessOrderRequest OrderRequest) {
  
  //http callout to payment gateway
  
  //post call code to update database with transaction details
  
  }
  </code></pre>
  
  <p><strong>REST call from client side</strong></p>
  
  <pre><code> forceTKClient.apexrest('/v1/orders/' ,
      function(data, textStatus, jqXHR){
          //process = data;
          console.log("****Response Success : "+JSON.stringify(data));
          scope.$apply(defered.resolve(data));
      }
  </code></pre>
  
  <p>Thanks in advance for your help!</p>