2

In my scenario i invoke a PUT callout to an external system After that GET callout is invoked that is supposed to get the updated record values

Problem: the output of step 2 shows the old record values and not the updated values Weird thing is that it shows the updated values after some time period(around 10 mins) However i want the updated values to be fetched in step 2 and not the old record values

this is the code for GET of step 2

 //*** Method to Get all Contracts from External system
public HttpResponse getHttpCall()
{
    System.debug(' ---------------- Inside getHttpCall --------------');
    Http httpProtocol=new Http();
    HttpRequest request=new HttpRequest();   
    String endpoint='http://xyz/customers';
    request.setEndPoint(endpoint);
    request.setHeader('Cache-Control', 'no-store');
    request.setMethod('GET');
    HttpResponse response=new HttpResponse();
    response=httpProtocol.send(request);
    System.debug(' ---------------- Inside getHttpCall --------------'+response.getBody());
    return response;
}

Any help would be appreciated

Thanks,

Neha Patil

2

It sounds like the system on the other end is handling the PUT request in an asynchronous manner, i.e. it's sending you a response before actually updating the system, and your GET is coming in too soon after.

An alternative might be that the values for the GET request are cached at the other end for some time and you're seeing old values until the cache gets refreshed.

Either way, this is not an issue on the Salesforce end of things. All you can really do is build in a delay of your own, maybe using time-based workflows or through scheduling an apex job.

  • hi LaceySnr, Thanks for your reply.. i would like to know if there is any parameter which i can set in my GET request that can fetch the updated records from the system?rather than from the cache? I am struggling through this issue for a long time now... Regards, Neha Patil – Neha Patil Jun 25 '14 at 6:59
  • 1
    @NehaPatil The caching (or other form of update delay e.g. scheduled processing) is likely to be within the service you are calling rather than something you can control. You should contact the company/person that implemented the service and discuss a solution with them. – Keith C Jun 25 '14 at 8:00
  • @NehaPatil One thing that might work is just adding another random number parameter on the end. It might be enough to fool the cache without breaking the service. – Matt Lacey Jun 25 '14 at 10:49
  • @LaceySnr:can you please elaborate? by showing an example? – Neha Patil Jun 26 '14 at 5:56
  • Perhaps just try something like this: endpoint='http://xyz/customers?cachebuster=' + system.now().milliseconds(); – Matt Lacey Jun 26 '14 at 6:33

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.