How do I read and set the LiveSync syncToken using REST in IDM (All versions)?
The purpose of this article is to provide information on reading and setting the LiveSync syncToken using the REST API in IDM.
Reading and setting the syncToken
You only need to set the syncToken on one instance in the cluster as the syncToken is shared by all instances in a cluster:
- Query the _id of the sync data using the following REST call:
- IDM 7 and later: $ curl -X GET -H "X-OpenIDM-Username: openidm-admin" -H "X-OpenIDM-Password: openidm-admin" -H "Accept-API-Version: resource=1.0" -H "Content-Type: application/json" "http://localhost:8080/openidm/repo/synchronisation/pooledSyncStage?_queryFilter=true&_fields=_id"
- Pre-IDM 7: $ curl -X GET -H "X-OpenIDM-Username: openidm-admin" -H "X-OpenIDM-Password: openidm-admin" -H "Content-Type: application/json" http://localhost:8080/openidm/repo/synchronisation/pooledSyncStage?_queryId=query-all-ids
Example response:{ "result": [ { "_id": "SYSTEMLDAPACCOUNT" } ], "resultCount": 1, "pagedResultsCookie": null, "totalPagedResultsPolicy": "NONE", "totalPagedResults": -1, "remainingPagedResults": -1 }
- Retrieve the last syncToken value using the following REST call, where SYSTEMLDAPACCOUNT is the _id value returned in step 1:
- IDM 7 and later: $ curl -X GET -H "X-OpenIDM-Username: openidm-admin" -H "X-OpenIDM-Password: openidm-admin" -H "Accept-API-Version: resource=1.0" -H "Content-Type: application/json" http://localhost:8080/openidm/repo/synchronisation/pooledSyncStage/SYSTEMLDAPACCOUNT Pre-IDM 7: $ curl -X GET -H "X-OpenIDM-Username: openidm-admin" -H "X-OpenIDM-Password: openidm-admin" -H "Content-Type: application/json" http://localhost:8080/openidm/repo/synchronisation/pooledSyncStage/SYSTEMLDAPACCOUNT
Example response:{ "_id": "SYSTEMLDAPACCOUNT", "_rev": "100", "connectorData": { "syncToken": 15000, "nativeType": "integer" } }
- Update the syncToken to the required value (15000 in this example) using the following REST call, where the other connectorData details are the ones returned in step 2 and _rev is set to null to update any revision since it will change every few seconds for small LiveSync intervals:
- IDM 7 and later: $ curl -X PUT -H "X-OpenIDM-Username: openidm-admin" -H "X-OpenIDM-Password: openidm-admin" -H "Accept-API-Version: resource=1.0" -H "Content-Type: application/json" -d '{ "connectorData": { "syncToken": 15000, "nativeType": "integer" }, "_id": "SYSTEMLDAPACCOUNT", "_rev": "null" }' http://localhost:8080/openidm/repo/synchronisation/pooledSyncStage/SYSTEMLDAPACCOUNT Pre-IDM 7: $ curl -X PUT -H "X-OpenIDM-Username: openidm-admin" -H "X-OpenIDM-Password: openidm-admin" -H "Content-Type: application/json" -d '{ "connectorData": { "syncToken": 15000, "nativeType": "integer" }, "_id": "SYSTEMLDAPACCOUNT", "_rev": "null" }' http://localhost:8080/openidm/repo/synchronisation/pooledSyncStage/SYSTEMLDAPACCOUNT
Note
See IDM (All versions) liveSync syncToken is out of sync with the DS changelog number for information on resetting the syncToken to zero instead of to a specific value.
See Also
Best practice for liveSync in IDM (All versions) with multiple DS instances
IDM (All versions) liveSync syncToken is out of sync with the DS changelog number
Related Training
N/A
Related Issue Tracker IDs
N/A