question

secretshardul avatar image
secretshardul asked Erick Ramirez edited

Why does paging through documents with Stargate return "Illegal base64 character 20"?

I am able to fetch documents using this API:

curl -X GET "https://$ASTRA_DB_ID-$ASTRA_DB_REGION.apps.astra.datastax.com/api/rest/v2/namespaces/my_namespace/collections/my_collection?page-size=1" \
  -H "X-Cassandra-Token: $ASTRA_AUTHORIZATION_TOKEN"

It gives me this result

{
    "pageState": "JDI3ODgyZTUyLTc2YTQtNGEwNi05MGU3LWVjODFkN2MzNDQzZRL/VVVVVVVVVVQEZGF0YeFVVVXwf////vB////+",
    "data": {
        "27882e52-76a4-4a06-90e7-ec81d7c3443e": {
            "data": "{\"name\": \"jack\"}"
        }
    }
}

As per the documentation, pagination can be done using 'page-state' query parameter. I tried using the 'pageState' value I obtained above, but am getting the below error. What is the correct way to paginate?

 Illegal base64 character 20

Here's the CURL with 'page-state':

curl -X GET "https://$ASTRA_DB_ID-$ASTRA_DB_REGION.apps.astra.datastax.com/api/rest/v2/namespaces/my_namespace/collections/my_collection?page-size=1&page-state=JDI3ODgyZTUyLTc2YTQtNGEwNi05MGU3LWVjODFkN2MzNDQzZRL/VVVVVVVVVVQEZGF0YeFVVVXwf////vB////+" \
  -H "X-Cassandra-Token: $ASTRA_AUTHORIZATION_TOKEN"
stargate
10 |1000

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

1 Answer

secretshardul avatar image
secretshardul answered smadhavan commented

Figured it out. The page-state must be made URL safe. I used this online tool and got

JDI3ODgyZTUyLTc2YTQtNGEwNi05MGU3LWVjODFkN2MzNDQzZRL%2FVVVVVVVVVVQEZGF0YeFVVVXwf%2F%2F%2F%2FvB%2F%2F%2F%2F%2B


Pagination now works as expected. Kindly update the Swagger documentation for benefit of other users.

2 comments Share
10 |1000

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

ds-steven-matison avatar image ds-steven-matison commented ·

Great job finding your own solution and updating the community with what you learned!

1 Like 1 ·
smadhavan avatar image smadhavan ♦ commented ·

Glad you've figured out yourself. As the requirement state, you will need to url encode your values.

Note that the where clause must be url encoded, so for e.g. curly brackets are escaped with \ and spaces must be replaced with %20.

1 Like 1 ·