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
VasaKVasaK 

Apex REST GET method is not returning modified (with PATCH) results

Hello,

Share additional information if anyone has experienced this issue or point me to a right direction is appreciated

I have created a new class to make a RESTful callsouts from Apex to Mule ESB.  My GET call is returning expected results but if I make a change (using PATCH externally as SF is not supporting from APEX) to one of the results, on the next GET modified results are not included.  This is not the scenario if I do GET from POSTMAN.

Say, my intial GET returns 50 rows and I make a changes to first row using PATCH externally, When I do another GET, I am getting 49 rows instead of 50 and modified data is not include in that 49 rows.

Here is my code (stripped down):

public void response(){
        HttpRequest reqData = new HttpRequest();
        reqData.setMethod('GET');
        reqData.setHeader('Content-Type','application/json');
        reqData.setHeader('Cache-Control','no-cache');
        //reqData.setHeader('Pragma', 'no-cache');
        //reqData.setHeader('Connection','Upgrade');
        reqData.setHeader('client_id', 'xxxxxx12312');
        reqData.setHeader('client_secret', '1231231xxxxxx');
        reqData.setEndpoint(endpointURL);
       
        Http http = new Http();
        try {
            HTTPResponse res = http.send(reqData);                     
            responseBody = res.getBody();
            System.debug('Return Val: ' + res.getBody());

        } catch(Exception exp){
            System.debug('exception '+exp);
        }
   }

Any information is appreciated

Thank you
 
Ajay K DubediAjay K Dubedi
Hi VasaK,
There might be some error in using 'PATCH' method. Since, there is no reason for the scenario you have mentioned. PATCH just changes the field value you want to update. Can you just recheck the PATCH code?