Changesets
Using changedRows
The Xporter on Demand API allows you to request only the records for a given endpoint and parameter combination that has changed since the last time you made a request. This is useful to keep processing of data in your application to a minimum.
Xporter on Demand uses changesets to track the delta of a dataset, supplying only new and changed rows, along with a new dataset for _deleted records that are no longer present.
- Important: When using changesets, it is essential to always use the same options and parameters for a given endpoint call. Changing these options will result in the data being filtered differently and returning unwanted deletions or changes,
To start a new changeset for an endpoint you simply need to pass the parameter changedRows with a value of "*****" with your request. This will begin a new changeset for you, for example:
- Example Request: .../Students/?changedRows=%2A
- Where "*" has been URL encoded as %2A
In the response you receive, there will now be two additional Json objects:
- changedRows
"__changedRows__": [
\{
"SnapshotDate": null,
"SnapshotRP": null,
"PreviousChangedRows": null,
"RequestedChangedRows": "*",
"NextChangedRows": "db69412c98782c1dd76addcad9b45be0",
"NextUrl": "?changedRows=db69412c98782c1dd76addcad9b45be0&page=1&pageSize=25"
\}
]
-
{ResultTable}_deleted
"Students_deleted": []
When you first initiate changedRows the _deleted object will be empty as there is nothing to compare against. On subsequent executions, if the returned main dataset no longer contains a record it had previously, the Id of that record will be listed in this object.
The changedRows object contains an attribute NextChangedRows. The value of this is a hash of the last returned dataset you received. On your next call to the same endpoint, using the same options and parameters, you can pass changedRows={receivedhash} and Xporter on Demand will compare the current full dataset it has, against the snapshot identified by your hash and return you only the things that have changed.
- Example Request: .../Students/?changedRows=db69412c98782c1dd76addcad9b45be0
If you need your application to request a full set again, resetting your changedRows status, simply pass "*" again to start a new change set.