API issue importing submissions to form

Email: support@getodk.org, @Sadiq_Khoja
Context:

The central ODK API is being used to import responses on a specific form, these responses are being generated in XML format on the version of the published form, the API does not return error and creates the submission on the form but without the responses or data:

Main issue:
The API satisfactorily creates the record of the response but creates it empty (without data), the strange thing is that the XML that is sent to it has the same structure as the form, so it is not clear why the complete submission is not created in the form.

API endpoint:
ODK_URL = "MY_DOMAIN/v1/projects/28/forms/Cargill/submissions"

Example answers for API in XML format:

<?xml version="1.0" encoding="utf-8"?> Wilmer Rocha gualterosMasculinoCC1124217151112421715111/20/19923144610214rochawilmer221@gmail.commeta50313TrabajadorEntrepalmas habitos_financierosAlex Escobar00005ConocimientosMás cursos

API response:
Successfully request: instanceId='9953c89b-e2ed-4aad-8090-3672685a8c6f' submitterId=775 createdAt=datetime.datetime(2025, 3, 18, 2, 22, 9, 875000, tzinfo=TzInfo(UTC)) deviceId=None reviewState=None userAgent='pyodk v1.1.0' instanceName=None updatedAt=None

Hi @Daniel_Zota ! :waving_hand:

I feel like there might be a small issue with how the data is being passed to the ODK Central server in XML format. Let’s troubleshoot it:

Try opening the following URL in your browser (make sure you’re logged into ODK Central and have access to the forms with blank or problematic submissions made via API):

YOUR_DOMAIN/v1/projects/28/forms/Cargill/submissions/(uuid_here).xml
  • Replace (uuid_here) with the UUID of any corrupted submission made via API.
  • Also, don’t forget to replace the colon : in the UUID with %3A.

Example:
Your final URL should look something like this:

YOUR_DOMAIN/v1/projects/28/forms/Cargill/submissions/uuid%3A988601a3-3d68-4687-9646-f9d2c783dfca.xml

Once you open it, take a look at how ODK has structured the submitted data in the XML format. If possible, feel free to share a sample here!

Hope this helps! Have a great day ahead! :smile:

Hello @MinimalPotato thanks for the reply

I have tested with some of the corrupted submission just as you explain and this is the XML response:

<data id="Cargill" version="1705417996">
<meta>
<instanceID>uuid:9415bd28-9fe2-48be-93c5-06b6ae423b81</instanceID>
</meta>
<SubmissionDate>2/8/23 11:53</SubmissionDate>
<datos_personales-participante>Alejandro cortés</datos_personales-participante>
<datos_personales-genero>Masculino</datos_personales-genero>
<datos_personales-id>CC</datos_personales-id>
<datos_personales-num_id>1152696286</datos_personales-num_id>
<datos_personales-num_id2>1152696286</datos_personales-num_id2>
<datos_personales-fecha_nac>5/10/1994</datos_personales-fecha_nac>
<datos_personales-celular>3193730312</datos_personales-celular>
<datos_personales-email>procesos.ambientales@entrepalmas.com.co</datos_personales-email>
<untitled26-departamento>antioquia</untitled26-departamento>
<untitled26-municipio>5001</untitled26-municipio>
<untitled26-rol>Trabajador</untitled26-rol>
<untitled26-empresa>Entrepalmas</untitled26-empresa>
<untitled26-Otro> </untitled26-Otro>
<untitled26-curso>habitos_financieros</untitled26-curso>
<untitled26-capacitador>Alex Escobar</untitled26-capacitador>
<untitled26-cedula_capacitador>0000</untitled26-cedula_capacitador>
<calificacion_curso>5</calificacion_curso>
<sobre_el_curso-temas_mostrados>Ingresos deben de mayor a los egresos</sobre_el_curso-temas_mostrados>
<sobre_el_curso-porque/>
<sobre_el_curso-recomendacion_curso>NingĂşna</sobre_el_curso-recomendacion_curso>
<sobre_el_curso-sugerencia_curso/>
<sobre_el_curso-compromiso/>
<firma/>
<KEY/>
<SubmitterID/>
<SubmitterName/>
<AttachmentsPresent/>
<AttachmentsExpected/>
<Status/>
<ReviewState/>
<DeviceID/>
<Edits/>
<FormVersion/>
</data>

there are fields that have the same name and structure as the odk form project where should be imported, so I can't figure out what's bad in the request to know populate the submission

Appreciate your kindly help, have a nice day too :slight_smile:

1 Like

Hey @Yordy_Gelvez ! :waving_hand:

Great job so far! :confetti_ball:

Now that we have the XML for the submission that isn't showing up in the data, the next step would be to compare it with one that does show up the data correctly - likely one submitted through ODK Collect or Enketo.

I'd suggest fetching the XML of a submission that shows up the data in the same way (the way we fetched an XML for the one that doesn't show up the data), and then do a side-by-side comparison. This should give us a clearer picture of whether there's something off with the XML format we're submitting via the ODK Central's REST API.

In the end, both XMLs should ideally look quite similar.

Let me know what you find! :smile:

3 Likes

Hello @MinimalPotato thanks for your guidance, help me a lot :smiley:

I have compared both xmls and you where right, there was differences in how the XML fields were structured.

Now the API works as expected and I'm able to finish the subs importation.
Thanks

3 Likes