2

I am trying to use the If-Modified-Since header with SObject Describe https://developer.salesforce.com/docs/atlas.en-us.api_rest.meta/api_rest/describe_global_with_ifmodified_header.htm

I want to know if the contact object's metadata has been modified since the specified date. I am using the Workbench REST Explorer.

My Request Header is

Content-Type: application/json; charset=UTF-8
Accept: application/json
If-Modified-Since: Sat, 29 Jul 2017 00:00:00 GMT

and endpoint is

/services/data/v39.0/sobjects/contact/describe

I have not made any changes to contact metadata but it is still returning metadata for contact instead of HTTP/1.1 304 Not Modified status code.

2 Answers 2

2

For anyone stumbling across this, I think I figured it out. It seems to be that the value used for the If-Modified-Since header is incorrect, i.e. even though the Contact object was not technically updated, Salesforce is returning a Last-Modified value in the response header when performing a GET to /services/data/v53.0/sobjects/Contact/describe which must then be used in further calls.

For example, in my DE org I have not made any updates on the Contact object, but the value being returned in the Last-Modified response header is Fri, 13 May 2022 04:48:00 GMT (the actual time of writing this answer is Fri, 13 May 2022 13:03:00 GMT).

So, specifying a value of anything greater than equal to that Last-Modified date will result in HTTP/1.1 304 Not Modified as desired. But any date less than that Last-Modified will return HTTP/1.1 200 OK and the describe payload.

The same is true for sobject describe too (/services/data/v53.0/sobjects). To use either of these services effectively in conjunction with the If-Modified-Since header, you must first retrieve the Last-Modified response header from an initial call, and then use that in conjunction with further calls (unless of course, there is a way of magically knowing the correct date/time).

1

From Salesforce Documentation:

If-Modified-Since:

The If-Modified-Since header is a time-based request header. The request is processed only if the data has changed since the date and time specified in the header. Otherwise, a 304 Not Modified status code is returned, and the request isn’t processed.

Here is the link - https://developer.salesforce.com/docs/atlas.en-us.api_rest.meta/api_rest/intro_rest_conditional_requests.htm

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .