# \[ODK Developers\] Posting the form definition file to ODKaggregate

**URL:** <https://forum.getodk.org/t/odk-developers-posting-the-form-definition-file-to-odkaggregate/2031>\
**Category:** Development\
**Created:** [March 12, 2013, 5:03pm UTC](https://forum.getodk.org/t/odk-developers-posting-the-form-definition-file-to-odkaggregate/2031 "2013-03-12T17:03:30Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![Mitch\_S](https://getodk.b-cdn.net/letter_avatar_proxy/v4/letter/m/3ec8ea/32.png) [@Mitch\_S](https://forum.getodk.org/u/Mitch_S)\
**Post date:** [March 12, 2013, 5:03pm UTC](https://forum.getodk.org/t/odk-developers-posting-the-form-definition-file-to-odkaggregate/2031/1 "2013-03-12T17:03:30Z")

</div>

I have no idea what that response from Curl means.

Note that form submissions into ODK Aggregate use standard plain old form  
posts. If you have a working ODK Aggregate, you can see the web page for  
form submission by opening a browser and pointing to .../formUpload. You  
can then view source on that page and reconstruct what you should be  
sending to the server.

i.e., if you had the ability to log into [opendatakit.appspot.com](http://opendatakit.appspot.com), you could  
get to this plain old web page via:

[http://opendatakit.appspot.com/formUpload](http://opendatakit.appspot.com/formUpload)

From there, your knowledge of Curl should enable you to construct the  
appropriate submission.

Mitch

> **···**
>
> On Tue, Mar 12, 2013 at 9:14 AM, wrote:
> 
> > Hi there,
> > 
> > I am working on a PHP application to manage forms and form data from  
> > outside ODK.  
> > My idea was to post the form definition file from within the application  
> > using curl.  
> > Something like:
> > 
> > ```
> > $ch = curl_init();
> > curl_setopt($ch, CURLOPT_HEADER, true);
> > curl_setopt($ch, CURLOPT_VERBOSE, 0);
> > curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
> > curl_setopt($ch, CURLOPT_USERAGENT, "Mozilla/4.0 (compatible;)");
> > curl_setopt($ch, CURLOPT_URL, '
> > 
> > ```
> > 
> > [http://myAggregateserver.org/ODKAggregate/formUpload](http://myAggregateserver.org/ODKAggregate/formUpload)');  
> > curl\_setopt($ch, CURLOPT\_USERPWD, "myUser:myPassword");  
> > curl\_setopt($ch, CURLOPT\_HTTPAUTH, CURLAUTH\_BASIC);  
> > curl\_setopt($ch, CURLOPT\_POST, true);  
> > $post = array(  
> > "form\_def\_file"=\>"@myformdefinition.xml",  
> > );  
> > curl\_setopt($ch, CURLOPT\_POSTFIELDS, $post);  
> > $response = curl\_exec($ch);
> > 
> > This does not work however.  
> > The application returns: "Resource id #2"
> > 
> > Is there anyone who has an idea how to do this?
> > 
> > Cheers!
> > 
> > Wiebe
> > 
> > --  
> > You received this message because you are subscribed to the Google Groups  
> > "ODK Developers" group.  
> > To unsubscribe from this group and stop receiving emails from it, send an  
> > email to [opendatakit-developers+unsubscribe@googlegroups.com](mailto:opendatakit-developers+unsubscribe@googlegroups.com).  
> > For more options, visit [https://groups.google.com/groups/opt\_out](https://groups.google.com/groups/opt_out).
> 
> --  
> Mitch Sundt  
> Software Engineer  
> University of Washington  
> [mitchellsundt@gmail.com](mailto:mitchellsundt@gmail.com)

---

<div class="post-metadata">

**Author:** ![Mitch\_S](https://getodk.b-cdn.net/letter_avatar_proxy/v4/letter/m/3ec8ea/32.png) [@Mitch\_S](https://forum.getodk.org/u/Mitch_S)\
**Post date:** [March 25, 2013, 4:50pm UTC](https://forum.getodk.org/t/odk-developers-posting-the-form-definition-file-to-odkaggregate/2031/2 "2013-03-25T16:50:41Z")

</div>

Yes. See /formUpload

At the moment, the servlet is not reporting invalid forms correctly. Seems  
to be a 1.3 regression.  
If it were reporting invalid forms correctly, you would see an error page  
other than the over-quota page that it now seems to display.

Mitch

> **···**
>
> On Sun, Mar 24, 2013 at 11:13 AM, wrote:
> 
> > On Tuesday, March 12, 2013 10:03:30 PM UTC+5, Mitch wrote:
> > 
> > > I have no idea what that response from Curl means.
> > > 
> > > Note that form submissions into ODK Aggregate use standard plain old  
> > > form posts. If you have a working ODK Aggregate, you can see the web page  
> > > for form submission by opening a browser and pointing to .../formUpload.  
> > > You can then view source on that page and reconstruct what you should be  
> > > sending to the server.
> > > 
> > > i.e., if you had the ability to log into [opendatakit.appspot.com](http://opendatakit.appspot.com), you  
> > > could get to this plain old web page via:
> > > 
> > > [http://opendatakit.appspot.com/formUpload](http://opendatakit.appspot.com/formUpload)
> > > 
> > > From there, your knowledge of Curl should enable you to construct the  
> > > appropriate submission.
> > > 
> > > Mitch
> > > 
> > > On Tue, Mar 12, 2013 at 9:14 AM, [in...@webwolf.nl](mailto:in...@webwolf.nl) wrote:
> > > 
> > > Hi there,
> > > 
> > > I am working on a PHP application to manage forms and form data from  
> > > outside ODK.
> > > 
> > > My idea was to post the form definition file from within the application  
> > > using curl.
> > > 
> > > Something like:
> > > 
> > > ```
> > > $ch = curl_init();
> > > 
> > > curl_setopt($ch, CURLOPT_HEADER, true);
> > > 
> > > curl_setopt($ch, CURLOPT_VERBOSE, 0);
> > > 
> > > curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
> > > 
> > > curl_setopt($ch, CURLOPT_USERAGENT, "Mozilla/4.0 (compatible;)");
> > > 
> > > curl_setopt($ch, CURLOPT_URL, '
> > > 
> > > ```
> > 
> > [http://myAggregateserver.org/ODKAggregate/formUpload](http://myAggregateserver.org/ODKAggregate/formUpload)');
> > 
> > > ```
> > > curl_setopt($ch, CURLOPT_USERPWD, "myUser:myPassword");
> > > 
> > > curl_setopt($ch, CURLOPT_HTTPAUTH, CURLAUTH_BASIC);
> > > 
> > > curl_setopt($ch, CURLOPT_POST, true);
> > > 
> > > $post = array(
> > > 
> > > "form_def_file"=>"@myformdefinition.xml",
> > > 
> > > );
> > > 
> > > curl_setopt($ch, CURLOPT_POSTFIELDS, $post);
> > > 
> > > $response = curl_exec($ch);
> > > 
> > > ```
> > > 
> > > This does not work however.
> > > 
> > > The application returns: "Resource id #2"
> > > 
> > > Is there anyone who has an idea how to do this?
> > > 
> > > Cheers!
> > > 
> > > Wiebe
> > > 
> > > --
> > > 
> > > You received this message because you are subscribed to the Google  
> > > Groups "ODK Developers" group.
> > > 
> > > To unsubscribe from this group and stop receiving emails from it, send  
> > > an email to [opendatakit-developers+unsubscribe@googlegroups.com](mailto:opendatakit-developers+unsubscribe@googlegroups.com).
> > > 
> > > For more options, visit [https://groups.google.com/groups/opt\_out](https://groups.google.com/groups/opt_out).
> > > 
> > > --  
> > > Mitch Sundt  
> > > Software Engineer  
> > > University of Washington  
> > > [mitche...@gmail.com](mailto:mitche...@gmail.com)
> > 
> > Hi everyone,
> > 
> > I have a questions along the same line. We have a use case for one of our  
> > upcoming installations where we would be dynamically designing forms and  
> > want to be able to upload them to aggregate through some API call (so that  
> > collect application can download this from the server, fill in the values  
> > and submit it back to aggregate). I see from above that form submission is  
> > a simple http post method. Is it the same if we are uploading a new form  
> > (empty...not a data submission) for a new survey that we now want to  
> > conduct without using the designer etc.
> > 
> > Thanks for any help or suggestions in this regard  
> > Zaineb
> > 
> > --  
> > You received this message because you are subscribed to the Google Groups  
> > "ODK Developers" group.  
> > To unsubscribe from this group and stop receiving emails from it, send an  
> > email to [opendatakit-developers+unsubscribe@googlegroups.com](mailto:opendatakit-developers+unsubscribe@googlegroups.com).  
> > For more options, visit [https://groups.google.com/groups/opt\_out](https://groups.google.com/groups/opt_out).
> 
> --  
> Mitch Sundt  
> Software Engineer  
> University of Washington  
> [mitchellsundt@gmail.com](mailto:mitchellsundt@gmail.com)
