Update Data
This endpoint allows you to update data within a database. Unlike the Add Data endpoint with refresh set to 1, using this endpoint allows selective updating leading to greater efficiencies of updating data – you can update individual rows rather than re-uploading your entire dataset each time there is a modification.
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 update the data of | |
data | {XML/unicode} | Specify the rows you wish to update and the value for the column(s) you wish to update in that row. Structure your XML with each row you wish to update as a parent tag. You then have subtags matching the column_ids for your database (which you wish to update) with the actual value for that column inside the tag |
You can provide two conditions for selecting the row:
row_id– the id of the row as in the Xtracta App.- WHERE style condition – use any field’s value as a key, e.g. "<row condition="{column_id}='{value}'">"
Example XML for data:
<row id="4">
<column id="1">value1</column>
<column id="2">value2</column>
<column id="3">value3</column>
</row>
<row id="5">
<column id="1">value4</column>
<column id="2">value5</column>
<column id="3">value6</column>
</row>
<row condition="3='sample_value'">
<column id="2">value7</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 records which 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_update HTTP/1.1
api_key=123&database_id=456789&data={xml here}
Sample Response
<?xml version="1.0" encoding="UTF-8"?>
<databases_response>
<status>200</status>
<message>The request has been successfully processed</message>
<affected_records>1</affected_records>
<data>
<row id="1" response="Record Updated"/>
</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:attribute name="response" 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>