ODK Central OData API: Return "updatedAt" dates

1. What is the general goal of the feature?

The current implementation of ODK Central's OData API delivers a submissionDate field for the Data Document endpoint which represents the original date and time when the submission was created. However, since ODK v1.2, submissions can be edited and therefore date/time of the last edit can change. Central's REST API considers this latest change and also delivers an updatedAt field for submissions, but for the OData API, this kind of field is not available.

See: https://odkcentral.docs.apiary.io/#reference/odata-endpoints/odata-form-service/data-document

I would like to suggest to add an updatedAt field to the response of the OData Data Document endpoint which resembles the latest edit of each submission (or the creation date, if there are no edits yet).

Ideally, the new field is also filterable.

2. What are some example use cases for this feature?

In our case, we are using the OData API to pull the most recent submissions into a different system. Since edits are possible, we can no longer tell if a submission has changed by its meta data.

3. What can you contribute to making this feature a reality?

We can offer to implement this feature if it is appreciated by the ODK team and community. We are open for a different naming convention for the field.

Hi @vlehn! We actually just implemented this, so this functionality should be available as part of v1.3. The OData response will have an updatedAt field under __system, which will be the same as the updatedAt field from the REST API. It will be possible to filter on updatedAt.

updatedAt is updated when a submission has been edited or when its metadata (its review state) has been updated.

As with the REST API, updatedAt in the OData response will be null when a submission is first created. That means that if you want to fetch all submissions created or updated since a certain date/time, the value of the OData $filter could be something like:

__system/submissionDate gt 2021-08-04T01:23:45.678Z or __system/updatedAt gt 2021-08-04T01:23:45.678Z
2 Likes

Hi Matthew,

this is great news! What a fate that you implemented this just so few days ago :slight_smile:

I just found the commit, just in case others would like to cherry-pick as well! https://github.com/getodk/central-backend/commit/7eb51e1cfbd9f965af746a506100e6368d14bf3e

3 Likes

Hi,
Can we get odata as per the https://services.odata.org/v4/Northwind/Northwind.svc/
from ODK Central?

I have tried the odata link available in ODK Central. Receiving the below error message
*

When called with an action of type "RA/CRUD_GET_LIST_SUCCESS", the slice reducer for key "total" returned undefined. To ignore an action, you must explicitly return the previous state. If you want this reducer to hold no value, you can return null instead of undefined.

Objective: to get the submission data from ODK Central using odataprovider

Thanks in advance.

Hi @rameshbhalla81,

Not sure how comprehensively the Central API covers the OData spec, but the API docs are the ultimate reference and come with working examples. Super neat for development of your own clients!

https://odkcentral.docs.apiary.io/#