Expensify.org/hunger SNAP campaign status
We’re no longer accepting new participants as our focus is on reimbursing existing claims. While we’re unable to provide a specific timeline on when your report will be reimbursed, we’re doing our best to drive donations and keep reimbursements moving forward. If you know anyone who can donate to this campaign please encourage them to enable Personal or Corporate Karma on their Expensify account.

We're currently experiencing issues with our American Express and Capital One connections. Please visit our status page for more details and to subscribe to updates.

Why do I receive a 402 for export report request from Salesforce?

sniemzsniemz Expensify Customer Posts: 5 Expensify Newcomer

Hi together,

I am building an integration from Expensify to Salesforce for my company and I manage to successfully request data from the integration service. However I had now to use a different class in Salesforce to send the requests and suddenly I receive an error message "Authentication error; 402". Switching back to my old code the request works still fine. Can you help me what the issue is here? Would it help to paste the apex code?

Answers

  • Sonia LiapounovaSonia Liapounova Expensify Team Posts: 98 Expensify Team

    @sniemz it's hard to guess why you're running into this error without seeing your code. If you could share the code that's throwing the error, that would be very helpful!

  • sniemzsniemz Expensify Customer Posts: 5 Expensify Newcomer

    The code is run in salesforce apex:

    public Object exportReport(){
    
            // create continuation with timeout
            Continuation con = new Continuation(60);
            // set callback method
            con.ContinuationMethod = 'processExportResponse';
    
            // create request
            Http http = new Http();
            HttpRequest request = new HttpRequest();
            request.setMethod('POST');
            request.setEndpoint('callout:Expensify_API');    
            request.setHeader('Content-Type', 'application/x-www-form-urlencoded'); 
            request.setBody('requestJobDescription={"type":"file","credentials":{"partnerUserID":"{!$Credential.Username}","partnerUserSecret":"{!$Credential.Password}"},"onReceive":{"immediateResponse":["returnRandomFileName"]},"inputSettings":{"type":"combinedReportData", "employeeEmail":"'+employeeEmail+'","filters":{"reportIDList":"'+expensifyReportID+'"}},"outputSettings":{"fileExtension":"csv"}}');
    
            System.debug(request.getBody());
            // add callout request to continuation
            this.exportR_requestLabel = con.addHttpRequest(request);
    
            // return continuation object
            return con;
        }
    
        // callback method from export report
        public Object processExportResponse (){
            // get response from unique continuation label
            HttpResponse response = Continuation.getResponse(this.exportR_requestLabel);
            // set output to be displayed on Visualforce page
            this.exportR_result = response.getBody();
    
            // return null to re-render original Visualforce page
            return null;
        }
    
    ```
    
  • Francois LaithierFrancois Laithier Expensify Team Posts: 24 Expensify Team
    edited April 17

    Hi @sniemz ,

    I see a System.debug(request.getBody()); in your code. Can you please double-check your debug logs to make sure that the requestJobDescription parameter contains a properly formatted "credentials":{"partnerUserID":"aa_something", "partnerUserSecret":"actual value"}, and ensure that the partner user ID and secret are the same as with your old code?

  • sniemzsniemz Expensify Customer Posts: 5 Expensify Newcomer

    Hi @Francois Laithier ,

    yes, I check again by creating one string that both the new and the old method refer to. The old method returns the file name the new one (the code is posted above) returns the Authentication error with a 402.

    Can you see anything in your logs?

Sign In or Register to comment.