Add Data
This endpoint allows you to insert new rows into a given database. It also allows you to delete all existing data as you add new data – potentially making updates of the Xtracta App easier since you do not need to track what data has changed since last sync – you can just re-sync completely.
POST Parameters
| Parameter | Required | Value | Description |
|---|---|---|---|
api_key | {key} | An API key that has access to the resource you want to query for | |
database_id | {integer} | The ID of the database which you wish to add data to | |
data | {xml/unicode} | The actual data you wish to upload. Structure your XML with each row as a parent tag, then have subtags matching the column_ids for your database with the actual value for that column inside the tag | |
refresh | 1, {null} | If you want to delete all data already in the database, pass the value of 1 with this POST field. Be very careful, this will delete all information! |
Data Refresh Warning: Using refresh=1 will delete all existing data in the database before adding new data. This action cannot be undone!
Example XML for data:
<row> <column id="1">The data for column 1 for this row</column> <column id="2">The data for column 2 for this row</column> </row> <row> <column id="1">The data for column 1 for this row</column> </row>
Response Information
| Element | Description |
|---|---|
<status> | A status code in response to the operation. |
<message> | Additional information about the operation – human readable. |
<affected_records> | The number of rows that were affected by the operation. |
<data> | A container for information about the specific rows that were added. |
<data>→<row> | The rows (and their Ids) which were added. |
Example
Sample Request
POST https://api-app.xtracta.com/v1/databases/data_add HTTP/1.1
api_key=123&database_id=456789&data={xml here}&refresh=1
Sample Response
<?xml version="1.0" encoding="UTF-8"?>
<databases_response>
<status>200</status>
<message>The request has been successfully processed</message>
<affected_records>4</affected_records>
<data>
<row id="50" />
<row id="51" />
</data>
</databases_response>
Schema Definition
<?xml version="1.0" encoding="UTF-8"?>
<xs:schema xmlns:xs="http://www.w3.org/2001/XMLSchema" elementFormDefault="qualified">
<xs:simpleType name="ConfidenceType">
<xs:union>
<xs:simpleType>
<xs:restriction base="xs:integer">
<xs:minInclusive value="0"/>
<xs:maxInclusive value="100"/>
</xs:restriction>
</xs:simpleType>
<xs:simpleType>
<xs:restriction base="xs:string">
<xs:enumeration value=""/>
</xs:restriction>
</xs:simpleType>
</xs:union>
</xs:simpleType>
<xs:complexType name="RowType">
<xs:simpleContent>
<xs:extension base="xs:string">
<xs:attribute name="id" type="xs:string" use="required"/>
</xs:extension>
</xs:simpleContent>
</xs:complexType>
<xs:complexType name="DataType">
<xs:sequence>
<xs:element name="row" type="RowType" maxOccurs="unbounded"/>
</xs:sequence>
</xs:complexType>
<xs:element name="databases_response">
<xs:complexType>
<xs:sequence>
<xs:element name="status" type="xs:positiveInteger"/>
<xs:element name="message" type="xs:string"/>
<xs:element name="affected_records" type="xs:nonNegativeInteger"/>
<xs:element name="data" type="DataType"/>
</xs:sequence>
</xs:complexType>
</xs:element>
</xs:schema>