Query API Response
XML Response
A successful request to the Query API will result in a response of the following format:
<wufoo_query success="true">
<total_records>Content</total_records>
<query_headers>Content</query_headers>
<query_records>Content</query_records>
</wufoo_query>
Each child node will contain its own structure, explained below.
total_records
This node has no child nodes, and contains a number representing the total amount of entries your form has collected. It is not the total amount of records returned by the query. The purpose of this node is to aid with processes such as paging. For example, you may show your users records 1 through 20 of 285. By providing the total (285 in this case), you know how far to let them page through.
<total_records>285</total_records>
query_headers
The purpose of this node is to provide you with the field information. For example, if you had a form with a First Name and Last Name field, then this node would contain two children. Each child gives information about each particular field, as shown below.
<query_headers>
<header>
<id>1</id>
<title>First Name</title>
<type>text</type>
</header>
<header>
<id>2</id>
<title>Last Name</title>
<type>text</type>
</header>
</query_headers>
Each header has information associated with it:
- id - This ID is important because the data returned in
<wufoo_records>can be associated with it. - title - The name of the field.
- type - The type of data stored in this field. This helps because it allows you to add additional formatting to the data as you display it. Valid values are: text, textarea, phone, europhone, date, eurodate, time, money, number, email, url, select, radio, address, name, checkbox, and file.
query_records
This last node contains the actual data you were querying. Continuing the the example in query_headers, the response would look like this:
<query_records>
<record>
<data type="text">Bob</data>
<data type="text">Wilson</data>
</record>
<record>
<data type="text">Steve</data>
<data type="text">Johnson</data>
</record>
</query_records>
Each <record> node is the equivalent to 1 submission into your form. And each child is the data in 1 field of your form. The data fields are in the same order as the header fields, so in the first <record> node it means someone typed ‘Bob’ as their first name.
Error Handling
If your request to the Query API is invalid, or if it fails in any way, an error message will be returned. The response will contain an error node, and success will be set to false.
<wufoo_query success="false">
<error>Error Message</error>
</wufoo_query>
To see a list of all possible errors, and what they mean, check out the error guide.