How to use the continuationToken when calling Azure Storage Tables with Azure Storage SDK v59.0.0 in GO

Viewed 163

Querying a table using the continuationToken provided in the first call fails but it could be I'm not using it correctly.

The table should return the records regardless if it's the first call (no continuationToken) or on subsequent calls (with continuationToken)

How can we reproduce it?

func QueryTableByContinuationToken(azureStorageAccountName string, azureStorageAccountKey string, tableName string, continuationToken string) (*storage.EntityQueryResult, error) {

    table, err := getTableReference(azureStorageAccountName, azureStorageAccountKey, tableName)
    if err != nil {
        return nil, errors.Wrap(err, "failed to get azure storage table reference")
    }

    result, err := table.QueryEntities(30, storage.FullMetadata, &storage.QueryOptions{Top: 0})
    if err != nil {
        return nil, errors.Wrap(err, "failed to query azure storage table")
    }

    result.QueryNextLink.NextLink = &continuationToken //is this the right way?

    return result.NextResults(nil)
}

calling the previous method passing the continuationToken that looks like this:

"https://<account>.table.core.windows.net/<table>?%24filter=PartitionKey+eq+%272021-11-01%27+and+Timestamp+le+datetime%272021-11-01T23%3A00%3A00Z%27&%24top=50&NextPartitionKey=1%2116%21MjAyMS0xMS0wMQ--&NextRowKey=1%2116%21MTY6MjI6NDEuMzk3&timeout=30"

returns a nil result with an error struct of type github.com/Azure/azure-sdk-for-go/storage.AzureStorageServiceError and the following content:

{Code: "", Message: "Response body could no be unmarshaled: invalid character '<' looking for beginning of value. Body: <?xml version=\"1.0\" encoding=\"utf-8\"?><error xmlns=\"http://schemas.microsoft.com/ado/2007/08/dataservices/metadata\"><code>AtomFormatNotSupported</code><message xml:lang=\"en-US\">Atom format is not supported.\nRequestId:8e2d22cb-e002-001b-3e54-cf3ce9000000\nTime:2021-11-01T19:16:39.5611825Z</message></error>.", AuthenticationErrorDetail: "", QueryParameterName: "", QueryParameterValue: "", Reason: "", Lang: "", StatusCode: 415, RequestID: "8e2d22cb-e002-001b-3e54-cf3ce9000000", Date: "Mon, 01 Nov 2021 19:16:39 GMT", APIVersion: "2018-03-28"}

is there a better way to use the continuationToken?

0 Answers
Related