Hello, I'm using the OData endpoints to import, with Apps Script, the data from a set of forms to Google Sheets, where this data is processed. It's working perfectly.
The data obtained by the path server/v1/projects/{projectId}/forms/{name}.svc/Submissions/?$format=json
includes the "review state" of each submission. However, I also need to retrieve:
1 - the user responsible for the last review;
2 - the date of the most recent review;
3 - the comment of the last review, if any.
Is there any way to make this request via OData?
Thanks!
Hi! What you're referring to are the audit logs
. We may use the submission-specific audit logs available via ODK Central's REST API, or the broader server audit logs.
Option 01: For an individual submission, you can retrieve the user who performed the last review
, the timestamp of that last review
, and any comment associated to that last review
. Each API request returns audit details for a single submission.
GET /v1/projects/{projectId}/forms/{xmlFormId}/submissions/{instanceId}/audits
Option 02: However, if you have administrator access to ODK Central, you can use the server-level audit logs endpoint. This allows you to filter for submission updates and retrieve the review details for all submissions in a single API call which can be analyzed to get the required ones.
GET /v1/audits
Hope this helps - great day!
1 Like
Thank you very much for the answer!
Option 2 seems almost ideal to me. It also seems more efficient to have a single API request, which can be cross-referenced with the instanceIds
later.
Is the server-level audit logs endpoint only available to admins? Is there a similar alternative for project viewers? Accessing audits by project or form would also work.
The login we use to import the data into Google Sheets is a project viewer login.
Yes, access to that endpoint is currently restricted to administrators within the ODK Central deployment, as it one of the system level
endpoint.
Hmm, as far as I know, filtering audits by project or form and making them available to the project viewer isn't currently supported in that manner yet.
Given that, Option 1 might be the most viable approach at this stage, as even if we were to fetch the system level audit logs
, they would still require further analysis to meaningfully interpret the required data.
Hope this helps! Great day!