简体   繁体   中英

How do I use the "If-Modified-Since" in the Salesforce v55.0 Rest API?

According to the documentation:

"An optional header specifying a date and time. The request returns records that have been modified after that date and time."

I am making a request to the following endpoint:

/services/data/v55.0/sobjects/Contact/{id}

With the following headers:

GET

Content-Type: "application/json" Authorization: "Bearer {access_token}" "If-Modified-Since": Thu, 08 Sep 2022 16:54:10 GMT

The header of the response contains the "Last-Modified" date/time of the SObject row that I requested and the date is "Thu, 08 Sep 2022 15:54:10 GMT".

How is it possible that the api is returning the data of the contact if it has not been modified since the time in my request?

Note: When I change the date/time in my request to "Thu, 08 Sep 2022 15:54:11 GMT", I see the correct behaviour and a 304 Not Modified is returned. However, should the time be moved forward by an hour the data is returned with a 200 OK

This can be a bug in the server implementation.

Another explanation that the server time is not properly set. Looks like in the case of salesforce this is true. A possible workaround is strictly using the value they send in the Last-Modified header instead of the current time of the client's computer. https://salesforce.stackexchange.com/a/375976

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM