Fetching next page of constituents returns "InvalidSortTokenValueFormat" for sort_token field

Hello!

I'm trying to implement a simple fetch-all script to get all the Constituent records from one of our customers accounts. First page of results contains a "next_link" value in it's payload which i'm  also using to fetch a second page of constituents but doing so results in API returning 400 error with a following content:

[

  {

    "message": "The provided sort token's format is invalid.",

    "error_name": "InvalidSortTokenValueFormat",

    "error_code": 14,

    "raw_message": "The provided sort token's format is invalid."

  }

]

I'm pretty concerned by this as i'm using the exact sort_token returned by a first page request. Request URL looks as follows:

https://api.sky.blackbaud.com/constituent/v1/constituents?fields=id%25252Cdate_added%25252Cemail%25252Cname%25252Cphone%25252Ctype%25252Clookup_id&include_deceased=False&include_inactive=False&sort_token=ew0KICAiRGF0ZSI6IG51bGwsDQogICJJZCI6ICIxMzc1IiwNCiAgIkNvbHVtbiI6IDQzLA0KICAiRGlyZWN0aW9uIjogMA0KfQ==


I also tried url-escaping the == chars which resulted in a following url:

https://api.sky.blackbaud.com/constituent/v1/constituents?fields=id%25252Cdate_added%25252Cemail%25252Cname%25252Cphone%25252Ctype%25252Clookup_id&include_deceased=False&include_inactive=False&sort_token=ew0KICAiRGF0ZSI6IG51bGwsDQogICJJZCI6ICIxMzc1IiwNCiAgIkNvbHVtbiI6IDQzLA0KICAiRGlyZWN0aW9uIjogMA0KfQ%3d%3d


And a following error:

[

  {

    "message": "The field 'sort_token' contains invalid data.",

    "error_name": "InvalidData",

    "error_code": 400,

    "raw_message": "The field 'sort_token' contains invalid data.",

    "error_args": [

    ]

  }

]



Any idea what am i doing wrong in here? Thanks in advance for any clues.

Comments

  • Chris Rodgers
    Chris Rodgers Blackbaud Employee
    Ninth Anniversary Kudos 3 Name Dropper Participant
    Hey Brendan,


    This is Chris with the SKY API team. I dug into your issue a bit, and from what I can tell, you've discovered an issue on our side. It appears that your sort_token is indicating that the list should be sorted by the constituent's last modified date; however, because that particular field (date_modified) was not included in your fields query parameter, the sort token from your previous request wasn't built correctly. I'm going to get this issue filed with our team.


    In the meantime, please discard the sort token and perform your original API request again. This time, to get a valid next link & sort_token, you can either remove the fields query parameter completely or update the fields query parameter to include the date_modified field:

    fields=date_added,date_modified,email,name,phone,type,lookup_id


    Sorry for the inconvenience there. Let me know if that doesn't resolve the issue for you.
  • Chris Rodgers
    Chris Rodgers Blackbaud Employee
    Ninth Anniversary Kudos 3 Name Dropper Participant
    Update: The issue Brendan reported has been resolved. The workaround I described in my previous post is no longer necessary. Please follow up on this thread if you're still encountering this problem. Thanks!

Categories