Skip to main content
Question

Invalid syncToken when performing ISync on Message Store API

  • December 15, 2022
  • 3 replies
  • 418 views

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" }

  • New Participant
  • December 16, 2022

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.


PhongVu
Community Manager
Forum|alt.badge.img
  • Community Manager
  • December 16, 2022

Thanks for sharing your solution.


PhongVu
Community Manager
Forum|alt.badge.img
  • Community Manager
  • December 16, 2022

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


Cookie policy

We use cookies to enhance and personalize your experience. If you accept you agree to our full cookie policy. Learn more about our cookies.

 
Cookie settings