question

Josh Calloway avatar image
Josh Calloway asked Phong Vu answered

Invalid syncToken when performing ISync on Message Store API

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

sms and text messagingmessage
1 |3000

Up to 8 attachments (including images) can be used with a maximum of 1.0 MiB each and 10.0 MiB total.

Josh Calloway avatar image
Josh Calloway answered Phong Vu commented

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.

1 comment
1 |3000

Up to 8 attachments (including images) can be used with a maximum of 1.0 MiB each and 10.0 MiB total.

Phong Vu avatar image Phong Vu ♦♦ commented ·

Thanks for sharing your solution.

0 Likes 0 ·
Phong Vu avatar image
Phong Vu answered

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)
    }
}
1 |3000

Up to 8 attachments (including images) can be used with a maximum of 1.0 MiB each and 10.0 MiB total.

Developer sandbox tools

Using the RingCentral Phone for Desktop, you can dial or receive test calls, send and receive test SMS or Fax messages in your sandbox environment.

Download RingCentral Phone for Desktop:

Tip: switch to the "sandbox mode" before logging in the app:

  • On MacOS: press "fn + command + f2" keys
  • On Windows: press "Ctrl + F2" keys