ODKAggregate get submission list for forms


(Rulx Philomé Alexis) #1

Hello all,
Wish that you all doing good!!
I'm here to ask question about the Briefcase API.
I'm using this document to do what I want : https://github.com/opendatakit/opendatakit/wiki/Briefcase-Aggregate-API

Now, let me explain what I'm trying to do:

I have a Web application that is build with PHP. The need is to grab data from Aggregate and make them available via the Web Application without [exporting from Aggregate, with briefcase and after import to the database's app].

So I need to quickly grab the data using the briefcase API.
Based on the link provided above and the ODK briefcase code. I understand that I can realise those step:

  • List the forms with the: /xformsList
  • Get the definition with the: /formXml?formId=
  • Get the list of ids of the submitted form: view/submissionList?numEntries=100&cursor=&formId=MEooo
  • And after download each submission using : view/downloadSubmission

My problem right now is that when I'm trying to get the list of ids of the submitted forms ODK Aggregate redirect me to the logging screen of ODK Aggregate that ask me my credentials

So I need to know or to get those IDs

Thank you in advance for your help

(Rulx Philomé Alexis) #2

Hello all!!
I'm aswering my own question.

ODK Aggregate redirected me to the Log in page, because my request miss the Authorization header.
OpenRosa is based on the RFC2617 Digest Authentication.

This link https://docs.opendatakit.org/openrosa-authentication/ explain how to implement it.

So right now I can list all the instance of a Form with this Url : /view/submissionList
And also download a dedicated answer for a Form with this Url: /view/downloadSubmission

The problem for now is dealing with forms who have version.
I can download instances for forms who don't have version.
But I can't for the other forms

The error that I receive is:
HTTP Status 500 - top level group name: topElement is not as expected:

My formId string is as follow:
my_form_id[@version='3' and @uiVersion=null]/data[@key=uuid:3b475e55-c872-462b-b662-5d95e2d930cd]

If you have any idea please give me your help

Thank you!!

(Yaw Anokwa) #3

I'd recommend you step through the code at https://github.com/opendatakit/briefcase/blob/master/src/org/opendatakit/briefcase/util/ServerFetcher.java and see what we do there.

(Rulx Philomé Alexis) #4

Thank you @yanokwa

Right now I'm programming the logic in PHP in a way to export submissions as JSON.
This can be requested like a REST API.

Will share my code as soon as possible.

Thank you!