Required parameter form ID xml attribute missing when posting to REST/ODK Central

To investigate:

I try to build a large database by uploading via REST/POST Using Postman.
The form has only one field, I have added one entry manually and can retrieve it with:

https://odksg.crabdance.com/v1/projects/36/forms/JaNein/submissions/uuid:f7bb7a38-c71d-423f-859e-3ad70a6d3000.xml

Response is:

<?xml version='1.0' ?>
<data id="JaNein" version="vicPu2GyFeYYPzuNeVfB3R" xmlns:ev="http://www.w3.org/2001/xml-events" xmlns:orx="http://openrosa.org/xforms" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:odk="http://www.opendatakit.org/xforms" xmlns:h="http://www.w3.org/1999/xhtml" xmlns:jr="http://openrosa.org/javarosa">
    <janein>ja</janein>
    <meta>
        <instanceID>uuid:f7bb7a38-c71d-423f-859e-3ad70a6d3000</instanceID>
    </meta>
</data>

I tried to upload a clone as follows:

https://odksg.crabdance.com/v1/projects/36/forms/JaNein/submissions

with a file POST load following https://odkcentral.docs.apiary.io/#reference/forms-and-submissions/submissions/creating-a-submission:

<?xml version="1.0"?>
<data id="JaNein" version="vicPu2GyFeYYPzuNeVfB3R" xmlns:ev="http://www.w3.org/2001/xml-events" xmlns:orx="http://openrosa.org/xforms" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:odk="http://www.opendatakit.org/xforms"
      xmlns:h="http://www.w3.org/1999/xhtml" xmlns:jr="http://openrosa.org/javarosa">
  <orx:meta>
    <orx:instanceID>uuid:f7bb7a38-c71d-423f-859e-3ad70a6d3001</orx:instanceID>
  </orx:meta>
  <janein>ja</janein>
</data>

Note that I have incremented the uuid (3000->3001), but this is pure guesswork, because I did not find documentation on orx in Central.

This gives an error:

{
    "message": "Required parameter form ID xml attribute missing.",
    "code": 400.2,
    "details": {
        "field": "form ID xml attribute"
    }
}

At a first glance, I don't see anything unusual about the XML you're sending. Could you also share the XML of the form?

For more information about the structure of the XML, take a look at the ODK XForms specification. There you'll find a note about orx, as well as a description of instanceID.

Thanks Matthew, I had seen the specification but did not fully get what it means in this context. So I simply copied it from the Submit docs.

<?xml version="1.0"?>
<h:html xmlns="http://www.w3.org/2002/xforms" xmlns:ev="http://www.w3.org/2001/xml-events" xmlns:h="http://www.w3.org/1999/xhtml" xmlns:jr="http://openrosa.org/javarosa" xmlns:odk="http://www.opendatakit.org/xforms" xmlns:orx="http://openrosa.org/xforms"
        xmlns:xsd="http://www.w3.org/2001/XMLSchema">
  <h:head>
    <h:title>JaNein</h:title>
    <model odk:xforms-version="1.0.0">
      <itext>
        <translation default="true()" lang="Deutsch (de)">
          <text id="/data/janein:label">
            <value>Ja Nein</value>
          </text>
          <text id="/data/janein:hint">
            <value>Ja oder nein</value>
          </text>
          <text id="/data/janein/ja:label">
            <value>Ja</value>
          </text>
          <text id="/data/janein/nein:label">
            <value>Nein</value>
          </text>
        </translation>
      </itext>
      <instance>
        <data id="JaNein" version="vicPu2GyFeYYPzuNeVfB3R">
          <janein/>
          <meta>
            <instanceID/>
          </meta>
        </data>
      </instance>
      <bind nodeset="/data/janein" required="false()" type="string"/>
      <bind jr:preload="uid" nodeset="/data/meta/instanceID" readonly="true()" type="string"/>
    </model>
  </h:head>
  <h:body class="theme-grid pages">
    <select1 appearance="list-label" ref="/data/janein">
      <label ref="jr:itext('/data/janein:label')"/>
      <hint ref="jr:itext('/data/janein:hint')"/>
      <item>
        <label ref="jr:itext('/data/janein/ja:label')"/>
        <value>ja</value>
      </item>
      <item>
        <label ref="jr:itext('/data/janein/nein:label')"/>
        <value>nein</value>
      </item>
    </select1>
  </h:body>
</h:html>

I seem to be able to POST the form and submission without error when I use curl. That makes me think that it's not an issue with the XML or with Central's parsing of the XML, but rather with getting the XML to Central. Do you have better luck when you use curl to POST? Maybe Postman is sending the XML in a way that Central doesn't understand? (Maybe it's the difference between sending a string and sending a file?)

1 Like

Bummer! Sending it as string with Postman

{
    "instanceId": "uuid:f7bb7a38-c71d-423f-859e-3ad70a6d3002",
    "submitterId": 34,
    "deviceId": null,
    "createdAt": "2020-07-08T19:15:51.583Z",
    "updatedAt": null
}

Thanks. You saved my night