I am trying to use the Submission API, ultimately, to update a case by submitting a form with new data. However, at the moment, I can’t see any of my submissions I pushed through the API.
I am sending the post with:
curl -F "firstname.lastname@example.org" "https://www.commcarehq.org/a/PROJECT/receiver/" -u email@example.com
Upon completion, I get the success message:
<OpenRosaResponse xmlns="http://openrosa.org/http/response"><message nature="submit_success"> √ </message></OpenRosaResponse>
This form has one field called
mresult and I set the value in the xml file such as:
<mresult value="test" />
The rest of the XML contents I copied from the “Edit Form’s Source XML” window.
However, when I run reports on this form (data reports), I see zero submissions for this form.
What am I doing wrong?
In CommCareHQ’s reports, do you see your data in the “Raw Forms, Errors & Duplicates” page? Does that view map your form properly to an existing form type?
I do see it actually - but no, it says it’s an unknown form type. It also doesn’t have my username as being the one submitted. How can I associate it to the right form?
I think the confusion may be in what XML you submitted.
You mentioned you copied the XML from the “view source xml” section. That’s the definition of the XForm structure, rather than the result of the xform being filled out. You likely want to use a copy of the form which was submitted from Web Apps or Live Preview as the template you are using for the change you submit.
That did work! And by leaving in the
instanceID field, it actually updated the existing form, which was ideal in our situation.
My last question then is: is it possible to pull that XML from another API end point if we know the instance ID?
It’s possible to retrieve the Form Data through the API’s, but I’m not sure if or how it’s possible to retrieve the original raw XML.
It would be worth poking around the API’s page to see what’s available and in what formats.