Skip to main content

I am getting and invalid syncToken when performing and ISync on the message store after running the FSync to get a token. The FSync works fine but when I use the returned token to follow up with an ISync I get the error. I can also replicate the problem by just using the api interface at https://developers.ringcentral.com/api-reference/Message-Store/syncMessages. If I run an FSync and then copy the returned token into the form field and switch to ISync I get this error:

{ "errorCode": "InvalidParameter", "message": "Parameter [syncToken] is invalid", "errors": [ { "errorCode": "MSG-333", "message": "Parameter [syncToken] is invalid", "parameterName": "syncToken" } ], "parameterName": "syncToken" }

As a follow-up, it would appear that you can't use any of the date fields to run the ISync. Eliminating that from the parameters seems to have "resolved" the issue.


Thanks for sharing your solution.


Here is a simple example how to sync the message store in Node JS.

syncExtensionMessageStore("")

async function syncExtensionMessageStore(syncToken){
console.log("===== sync_extension_message_store ======")
var endpoint = '/restapi/v1.0/account/~/extension/~/message-sync'
var params = {}
if (syncToken == ""){
params = {
dateFrom: "2021-08-02T23:59:59.999Z",
syncType: 'FSync',
recordCount: 250
}
}else{
params['syncToken'] = syncToken
params.syncType = 'ISync'
params.recordCount = 250
}
try{
const resp = await platform.get(endpoint, params)
var jsonObj = await resp.json()
//console.log(jsonObj)
if (jsonObj.records.length > 0){
setTimeout(function(){
syncExtensionMessageStore(jsonObj.syncInfo.syncToken)
}, 2000)
}else{
console.log('Done!')
}
}catch (e){
console.log(e.message)
}
}

Reply