Submit form value with Form submision API Issue

(Swetanka Jaiswal) #1

I want to insert values in one of my form. I have copied the form submission xml format from the submit history option.
I change the values of the field and post the same xml to but nothing happens. No response. Also can not see entries in submission. I tried to post the XML with blank case id with no luck.

Please suggest what changes i need to make in the XML to submit new data in the form

(Cory Zue) #2

Hi Swetanka,

What response code are you getting from the server? It should respond with a 201 if you are submitting successfully. Any other response code implies something is going wrong.

Also if you can share the exact XML and code you are using for the submission, as well as any debug output that would be helpful.


(Swetanka Jaiswal) #3


<?xml version="1.0" ?> Swetanka 20 fhgfh 695c055903a24919ad2c59823272de48 ATEC18 Formplayer 2019-05-08T16:28:24.036+05:30 2019-05-08T16:28:44.832+05:30 cork 1652adae7ab1455b8332b7b4609fc7b0 c6ec4b4e-9f4f-4774-b0dd-21a54ecb1ab9 Formplayer Version: 2.45 0 I have changed the and value.

I am getting no response at all. I tried
curl -d @file.xml &
curl -F “xml_submission_file=@file.xml” “” -u
but no response

(Ethan Soergel) #4

Hi Swetanka,

Can you add --verbose to your curl commands? That will show more information about the request, including the response code. That will be useful in debugging.

The xml you pasted into your last message looks incomplete - I suspect the forum software tried formatting it. If you indent the code with four spaces, it will be marked as “preformatted”, so we can see exactly what you typed. You can also put three backticks ``` above and below the code.

(Swetanka Jaiswal) #6

I am attaching XML and debug code as file
Debug Code

(Swetanka Jaiswal) #7

Why my posts are flagged?

(Ethan Soergel) #8

I see a few things in that debug output, the biggest of which is the HTTP response code:
HTTP/1.1 401 Unauthorized
There’s an authentication problem. If you look higher up in the output, it says:
Server auth using Basic with user '<username>'
The username contained there has two @ symbols, which is not a valid format for a commcare user.

To log in as a web user, you should use the account email address. For a mobile worker, you should use username@<project-name> This looks like a combination of the two formats.

(Swetanka Jaiswal) #9

Yeah I saw that but in my account the user name is email address only so where can I find the correct username?

(Swetanka Jaiswal) #10

I created a mobile user and now i’m getting success in the response. But can not see the posted entry in the form submissions.
Also the entry whose XML format I copied gets deleted on posting the value from the API. Can you please point me in right direction what changes we need to make in XML structure to work properly.

(Simon Kelly) #11

Any time you submit a form, if there is already a form with the same ID, then the new form will overwrite the old one. You should change the value of form/meta/instanceID for each new form.

You should be able to see form at:[FORM ID]/

and the case at[CASE ID]/

(Swetanka Jaiswal) #12

Should I put any random instance id there?

(Simon Kelly) #13

Yes, you should use a UUID. We usually use UUID v4.

(Swetanka Jaiswal) #14

I changed the instance id with a new UUID v4 string but no luck. Even tested by changing case id but same result.
Please compare my Original XML and edited XML with new values and plese suggest what is wrong?