Synchronize Resources Efficiently¶
Synchronizing data seems fairly easy at first sight but in the end an integrator would have to put a lot of thought in it in order to make it efficient and cover all the edge cases. To solve this we offer an "incremental synchronization". Using this method, you can keep the data of collections in sync easily. Whether a collection supports this feature is indicated by the availability of the ?syncModifications
-Parameter stated in the request description. Incremental synchronization consists of two stages:
- Initial full sync is performed once at the very beginning in order to fully synchronize the client’s state with the server’s state. The client will obtain a sync token that it needs to persist.
- Incremental sync is performed repeatedly and updates the client with all the changes that happened ever since the previous sync. Each time, the client provides the previous sync token it obtained from the server and stores the new sync token from the response.
Initial full sync¶
The initial full sync starts with the following request:
/integrations/inxmail-professional/mailing-synchronizations?syncModifications=true
If all resources are in the response, you will find a link called inx:upcoming-modifications
which contains the full link for the next incremental synchronization. You'll need to store the link.
Response with upcoming link on the last page:
...
"_links" : {
"self" : {...},
"inx:upcoming-modifications" : {
"href" : ".../mailing-synchronizations?syncToken=<syncTokenValue>&syncModifications=true"
}
}
Otherwise, if the result set is too large, and the response gets paginated, you will find a next
link instead of the inx:upcoming-modifications
link in the result.
Response with next link:
{
"_links" : {
"next" : {
"href" : "<baseUrl>/integrations/inxmail-professional/mailing-synchronizations?cursor=<cursorValue>"
}
}
}
Incremental sync¶
Incremental sync allows you to retrieve all the resources that have been modified since the last sync request. To do this, you need to perform a request with your most recent inx:upcoming-modifications
link.
/integrations/inxmail-professional/mailing-synchronizations?syncToken=<syncTokenValue>&syncModifications=true
In cases where many resources have changed since the last incremental sync request, you may find a next link instead of the inx:upcoming-modifications
link in the result. This indicates pagination is required until no more next
-link is provided.
Response with next link
...
"_links" : {
"self" : {...},
"next" : {
"href" : ".../mailing-synchronizations?cursor=<cursorValue>"
}
}
On the last page again you will find a inx:upcoming-modifications
link which you need to store for the next incremental synchronization.
Response with upcoming modifications link on the last page:
...
"_links" : {
"self" : {...},
"inx:upcoming-modifications" : {
"href" : ".../mailing-synchronizations?syncToken=<syncTokenValue>&syncModifications=true"
}
}
Things to consider
- At the moment you can not combine the parameter
?syncModifactions=true
with filters - Data is sorted by modificationDate. In large datasets with paginated results you occasionally will see the same record with updated data in a subsequent page. Make sure to process them in order or only keep the most recent record received by making use of the provided
modificationDate
. - If the incremental sync was not successful you can retry from the beginning using the most recent
inx:upcoming-modifications
link