How to use updated_since if I do not know the server date

Platform: Pare Javascript Web application

Browser, All but experimented in Chrome

URLs:: https://www.ritmenatura.cat/captura/index.htm?Language=eng

Description of problem (please provide a set of steps we can use to replicate the issue, and make as many as you need.):

Sometimes the creation of an observation returns before being completed. This results in a empty response. In this cases, we use the GET request of all my observations updated_since 30 seconds before “now”.

The problem is. There is no proper way to do this if you are not able to know the iNaturalist server date. In one case one of our web application users had the computer clock 5 minutes faster. This results in a situation where we are requesting “updated_since dates” that are in future from from iNaturalist server point of view.

Question: How to get the server date?

Step 1: POST a “complex” observation with the new API (https://api.inaturalist.org/v1/observations). It returns with 200 but and empty body. (As a consequence we have no idea of the id of the observation submitted)

Step 2: Do GET request with the old API https://www.inaturalist.org/observations/{UserName}.json?updated_since={date}
where “date” is the date of the local computer (we got it using date=new Date())
(our intention is to find our observation id and continue with adding things to it)

Step 3: “No results found” because the date of the computer is faster than the date of your server

We tried to get the Date from the HTTP headers. This is actually the server date!!. Unfortunately, we are doing a CORS request so some headers are not visible to our JavaScript code. In other to allow “Date” header to be exposed to our code the server should use “Access-Control-Expose-Headers: Date” but it does not and we cannot control the server configuration (as suggested by https://www.moesif.com/blog/technical/cors/Authoritative-Guide-to-CORS-Cross-Origin-Resource-Sharing-for-REST-APIs/)

We tried to find out the last observation in the server to know about its ID before doing anything and then use id_above to find only the recent observations including mine. I was not able to figure out a method to get the “last id”. Do you know how to do it?

Thanks for any clue.

what does this mean? as far as i can tell, if you do your promise chaining properly, you should always get a response that includes details of the new observation.

can you provide an example, along with snippets of code where you’re doing your POST?

if a moderator sees this, it might be time to close this bug report. there’s been no additional information provided (the user hasn’t visited the forum since the original post in the thread), and it’s not clear that there was actually a bug here.

Thanks - it sounds more like a question, so I moved it to #general.

This topic was automatically closed 60 days after the last reply. New replies are no longer allowed.