Sample code for 30+ languages & platforms
Visual FoxPro Requires Chilkat v11.6.0+

Amazon S3: List Object Versions and Delete Markers

See more S3 - REST Examples

List versions and delete markers under a prefix. Version IDs, including the literal null version ID, remain strings. IsLatest indicates the current entry, which can be a delete marker. This listing does not modify data. Requires s3:ListBucketVersions.

Follow both pagination markers, including after an empty page. With encoding-type=url, decode keys and NextKeyMarker once, but never decode the opaque version/upload ID. Repeated marker pairs and the 1000-page bound report incomplete enumeration. Pages are not an atomic snapshot, and no deprecated DisplayName field is required.

For general purpose S3 buckets, using regional HTTPS endpoints and AWS Signature Version 4. Directory buckets (S3 Express), access points, Outposts, and other AWS partitions need their own endpoint/authentication rules. Use a bucket name without dots for these virtual-hosted TLS examples; see the path-style example for dotted names.

Provide current IAM credentials in a private qa_data/aws/s3.json file with string fields access_key, secret_key, and session_token for temporary credentials. Prefer short-lived role credentials. This file is explicitly loaded; these examples do not discover profiles or refresh credentials. Keep it outside public content and source control. The session token is included in the signed request. TLS certificate verification is enabled on the Socket used by Rest.

Transport success and HTTP success are different. Keep full diagnostics private; signed requests and presigned URLs can contain credentials or grant access. For retryable reads use bounded backoff with jitter. Before retrying a write with an uncertain outcome, check the resource state. Keep keys, upload IDs, version IDs, ETags, and large sizes as strings.

AWS ListObjectVersions reference

Chilkat Visual FoxPro Downloads

Visual FoxPro
LOCAL lnSuccess
LOCAL loTextCompare
LOCAL loCredentials
LOCAL lnSameText1
LOCAL lnSameText2
LOCAL lcRegion
LOCAL lcBucketName
LOCAL loEndpoint
LOCAL loAws
LOCAL loRest
LOCAL lnSameText3
LOCAL loConnection
LOCAL loXml
LOCAL loSeenPages
LOCAL loMarkerPair
LOCAL lnMore
LOCAL lnPage
LOCAL lcResponseBody
LOCAL lnSameText4
LOCAL lnSameText5
LOCAL v
LOCAL lnSameText6
LOCAL loKeyv
LOCAL lnKeyvPluses
LOCAL lnSameText7
LOCAL lnSameText8
LOCAL lnSameText9
LOCAL lnSameText10
LOCAL lnSameText11
LOCAL d
LOCAL lnSameText12
LOCAL loKeyd
LOCAL lnKeydPluses
LOCAL lnSameText13
LOCAL lnSameText14
LOCAL lnSameText15
LOCAL lnSameText16
LOCAL lnSameText17
LOCAL lnSameText18
LOCAL lnSameText19
LOCAL lnSameText20
LOCAL lnSameText21
LOCAL loNextKey
LOCAL lnNextKeyPluses
LOCAL lcPair

lnSuccess = 0

*  StringBuilder compares text by value in every generated language.
loTextCompare = CreateObject('Chilkat.StringBuilder')
*  Assumes Chilkat is unlocked. See Global Unlock Sample.
lnSuccess = 0
*  Private configuration, not a file in public web content or source control.
*  Load current IAM credentials authorized for the S3 operation.
loCredentials = CreateObject('Chilkat.JsonObject')
loCredentials.Strict = 1
lnSuccess = loCredentials.LoadFile("qa_data/aws/s3.json")
IF (lnSuccess <> 1) THEN
    ? "Could not load private AWS credentials."
    RELEASE loTextCompare
    RELEASE loCredentials
    CANCEL
ENDIF

loTextCompare.Clear()
loTextCompare.SetString(loCredentials.StringOf("access_key"))
lnSameText1 = loTextCompare.ContentsEqual("",1)
IF ((loCredentials.JsonTypeOf("access_key") <> 1) OR (lnSameText1 = 1)) THEN
    ? "Missing or invalid access_key."
    RELEASE loTextCompare
    RELEASE loCredentials
    CANCEL
ENDIF

loTextCompare.Clear()
loTextCompare.SetString(loCredentials.StringOf("secret_key"))
lnSameText2 = loTextCompare.ContentsEqual("",1)
IF ((loCredentials.JsonTypeOf("secret_key") <> 1) OR (lnSameText2 = 1)) THEN
    ? "Missing or invalid secret_key."
    RELEASE loTextCompare
    RELEASE loCredentials
    CANCEL
ENDIF

*  General purpose bucket in the commercial AWS partition.
lcRegion = "us-west-2"
lcBucketName = "amzn-s3-demo-bucket"
loEndpoint = CreateObject('Chilkat.StringBuilder')
lnSuccess = loEndpoint.Append(lcBucketName)
IF (lnSuccess <> 1) THEN
    ? "Could not build text."
    RELEASE loTextCompare
    RELEASE loCredentials
    RELEASE loEndpoint
    CANCEL
ENDIF

lnSuccess = loEndpoint.Append(".")
IF (lnSuccess <> 1) THEN
    ? "Could not build text."
    RELEASE loTextCompare
    RELEASE loCredentials
    RELEASE loEndpoint
    CANCEL
ENDIF

lnSuccess = loEndpoint.Append("s3.")
IF (lnSuccess <> 1) THEN
    ? "Could not build text."
    RELEASE loTextCompare
    RELEASE loCredentials
    RELEASE loEndpoint
    CANCEL
ENDIF

lnSuccess = loEndpoint.Append(lcRegion)
IF (lnSuccess <> 1) THEN
    ? "Could not build text."
    RELEASE loTextCompare
    RELEASE loCredentials
    RELEASE loEndpoint
    CANCEL
ENDIF

lnSuccess = loEndpoint.Append(".amazonaws.com")
IF (lnSuccess <> 1) THEN
    ? "Could not build text."
    RELEASE loTextCompare
    RELEASE loCredentials
    RELEASE loEndpoint
    CANCEL
ENDIF

loAws = CreateObject('Chilkat.AuthAws')
loAws.AccessKey = loCredentials.StringOf("access_key")
loAws.SecretKey = loCredentials.StringOf("secret_key")
loAws.Region = lcRegion
loAws.ServiceName = "s3"
loAws.SignatureVersion = 4
loRest = CreateObject('Chilkat.Rest')
loRest.ConnectTimeoutMs = 20000
loRest.IdleTimeoutMs = 60000
lnSuccess = loRest.SetAuthAws(loAws)
IF (lnSuccess <> 1) THEN
    ? "Could not configure AWS signing."
    RELEASE loTextCompare
    RELEASE loCredentials
    RELEASE loEndpoint
    RELEASE loAws
    RELEASE loRest
    CANCEL
ENDIF

*  Temporary credentials require this token in every signed query.
*  Keep request URLs private. Do not clear this parameter between requests.
IF (loCredentials.HasMember("session_token") = 1) THEN
    IF (loCredentials.JsonTypeOf("session_token") <> 1) THEN
        ? "session_token must be a string."
        RELEASE loTextCompare
        RELEASE loCredentials
        RELEASE loEndpoint
        RELEASE loAws
        RELEASE loRest
        CANCEL
    ENDIF

    loTextCompare.Clear()
    loTextCompare.SetString(loCredentials.StringOf("session_token"))
    lnSameText3 = loTextCompare.ContentsEqual("",1)
    IF (lnSameText3 <> 1) THEN
        lnSuccess = loRest.AddQueryParam("X-Amz-Security-Token",loCredentials.StringOf("session_token"))
        IF (lnSuccess <> 1) THEN
            ? "Could not prepare the request."
            RELEASE loTextCompare
            RELEASE loCredentials
            RELEASE loEndpoint
            RELEASE loAws
            RELEASE loRest
            CANCEL
        ENDIF

    ENDIF

ENDIF

*  Connect to the SAME hostname used for TLS verification and request signing.
loConnection = CreateObject('Chilkat.Socket')
loConnection.RequireSslCertVerify = 1
loConnection.MaxReadIdleMs = 60000
loConnection.MaxSendIdleMs = 60000
lnSuccess = loConnection.Connect(loEndpoint.GetAsString(),443,1,20000)
IF (lnSuccess <> 1) THEN
    ? "TLS connection failed; inspect diagnostics privately."
    RELEASE loTextCompare
    RELEASE loCredentials
    RELEASE loEndpoint
    RELEASE loAws
    RELEASE loRest
    RELEASE loConnection
    CANCEL
ENDIF

lnSuccess = loRest.UseConnection(loConnection,1)
IF (lnSuccess <> 1) THEN
    ? "Could not attach the TLS connection."
    RELEASE loTextCompare
    RELEASE loCredentials
    RELEASE loEndpoint
    RELEASE loAws
    RELEASE loRest
    RELEASE loConnection
    CANCEL
ENDIF

loXml = CreateObject('Chilkat.Xml')
loXml.Strict = 1
lnSuccess = loRest.AddQueryParam("versions","")
IF (lnSuccess <> 1) THEN
    ? "Could not prepare the request."
    RELEASE loTextCompare
    RELEASE loCredentials
    RELEASE loEndpoint
    RELEASE loAws
    RELEASE loRest
    RELEASE loConnection
    RELEASE loXml
    CANCEL
ENDIF

lnSuccess = loRest.AddQueryParam("max-keys","1000")
IF (lnSuccess <> 1) THEN
    ? "Could not prepare the request."
    RELEASE loTextCompare
    RELEASE loCredentials
    RELEASE loEndpoint
    RELEASE loAws
    RELEASE loRest
    RELEASE loConnection
    RELEASE loXml
    CANCEL
ENDIF

lnSuccess = loRest.AddQueryParam("prefix","documents/")
IF (lnSuccess <> 1) THEN
    ? "Could not prepare the request."
    RELEASE loTextCompare
    RELEASE loCredentials
    RELEASE loEndpoint
    RELEASE loAws
    RELEASE loRest
    RELEASE loConnection
    RELEASE loXml
    CANCEL
ENDIF

lnSuccess = loRest.AddQueryParam("encoding-type","url")
IF (lnSuccess <> 1) THEN
    ? "Could not prepare the request."
    RELEASE loTextCompare
    RELEASE loCredentials
    RELEASE loEndpoint
    RELEASE loAws
    RELEASE loRest
    RELEASE loConnection
    RELEASE loXml
    CANCEL
ENDIF

loSeenPages = CreateObject('Chilkat.Hashtable')
loMarkerPair = CreateObject('Chilkat.JsonObject')
lnMore = 1
lnPage = 0
DO WHILE (lnMore = 1)
    IF (lnPage = 1000) THEN
        ? "Page limit reached; enumeration is incomplete."
        RELEASE loTextCompare
        RELEASE loCredentials
        RELEASE loEndpoint
        RELEASE loAws
        RELEASE loRest
        RELEASE loConnection
        RELEASE loXml
        RELEASE loSeenPages
        RELEASE loMarkerPair
        CANCEL
    ENDIF

    lcResponseBody = loRest.FullRequestNoBody("GET","/")
    IF (loRest.LastMethodSuccess <> 1) THEN
        ? "Request did not complete; inspect diagnostics privately."
        RELEASE loTextCompare
        RELEASE loCredentials
        RELEASE loEndpoint
        RELEASE loAws
        RELEASE loRest
        RELEASE loConnection
        RELEASE loXml
        RELEASE loSeenPages
        RELEASE loMarkerPair
        CANCEL
    ENDIF

    IF (loRest.ResponseStatusCode <> 200) THEN
        ? "S3 HTTP status: " + STR(loRest.ResponseStatusCode)
        lnSuccess = loXml.LoadXml(lcResponseBody)
        loTextCompare.Clear()
        loTextCompare.SetString(loXml.Tag)
        lnSameText4 = loTextCompare.ContentsEqual("Error",1)
        IF ((lnSuccess = 1) AND (lnSameText4 = 1)) THEN
            ? "S3 error code: " + loXml.GetChildContent("Code")
        ENDIF

        *  Keep signed headers, credentials, URLs, and full diagnostics private.
        *  A timeout may leave a write's outcome uncertain. Check before retrying.
        RELEASE loTextCompare
        RELEASE loCredentials
        RELEASE loEndpoint
        RELEASE loAws
        RELEASE loRest
        RELEASE loConnection
        RELEASE loXml
        RELEASE loSeenPages
        RELEASE loMarkerPair
        CANCEL
    ENDIF

    lnSuccess = loXml.LoadXml(lcResponseBody)
    IF (lnSuccess <> 1) THEN
        ? "Expected well-formed XML."
        RELEASE loTextCompare
        RELEASE loCredentials
        RELEASE loEndpoint
        RELEASE loAws
        RELEASE loRest
        RELEASE loConnection
        RELEASE loXml
        RELEASE loSeenPages
        RELEASE loMarkerPair
        CANCEL
    ENDIF

    loTextCompare.Clear()
    loTextCompare.SetString(loXml.Tag)
    lnSameText5 = loTextCompare.ContentsEqual("ListVersionsResult",1)
    IF (lnSameText5 <> 1) THEN
        ? "Unexpected S3 response element; this is not a successful result."
        RELEASE loTextCompare
        RELEASE loCredentials
        RELEASE loEndpoint
        RELEASE loAws
        RELEASE loRest
        RELEASE loConnection
        RELEASE loXml
        RELEASE loSeenPages
        RELEASE loMarkerPair
        CANCEL
    ENDIF

    v = 0
    DO WHILE (v < loXml.NumChildrenHavingTag("Version"))
        loXml.I = v
        loTextCompare.Clear()
        loTextCompare.SetString(loXml.GetChildContent("Version[i]|Key"))
        lnSameText6 = loTextCompare.ContentsEqual("",1)
        IF ((loXml.HasChildWithTag("Version[i]|Key") <> 1) OR (lnSameText6 = 1)) THEN
            ? "Missing response field: Version[i]|Key"
            RELEASE loTextCompare
            RELEASE loCredentials
            RELEASE loEndpoint
            RELEASE loAws
            RELEASE loRest
            RELEASE loConnection
            RELEASE loXml
            RELEASE loSeenPages
            RELEASE loMarkerPair
            CANCEL
        ENDIF

        loKeyv = CreateObject('Chilkat.StringBuilder')
        lnSuccess = loKeyv.Append(loXml.GetChildContent("Version[i]|Key"))
        IF (lnSuccess <> 1) THEN
            ? "Could not prepare the request."
            RELEASE loTextCompare
            RELEASE loCredentials
            RELEASE loEndpoint
            RELEASE loAws
            RELEASE loRest
            RELEASE loConnection
            RELEASE loXml
            RELEASE loSeenPages
            RELEASE loMarkerPair
            RELEASE loKeyv
            CANCEL
        ENDIF

        lnKeyvPluses = loKeyv.Replace("+","%2B")
        lnSuccess = loKeyv.Decode("url","utf-8")
        IF (lnSuccess <> 1) THEN
            ? "Could not decode a returned key."
            RELEASE loTextCompare
            RELEASE loCredentials
            RELEASE loEndpoint
            RELEASE loAws
            RELEASE loRest
            RELEASE loConnection
            RELEASE loXml
            RELEASE loSeenPages
            RELEASE loMarkerPair
            RELEASE loKeyv
            CANCEL
        ENDIF

        ? "Version key: " + loKeyv.GetAsString()
        loTextCompare.Clear()
        loTextCompare.SetString(loXml.GetChildContent("Version[i]|VersionId"))
        lnSameText7 = loTextCompare.ContentsEqual("",1)
        IF ((loXml.HasChildWithTag("Version[i]|VersionId") <> 1) OR (lnSameText7 = 1)) THEN
            ? "Missing response field: Version[i]|VersionId"
            RELEASE loTextCompare
            RELEASE loCredentials
            RELEASE loEndpoint
            RELEASE loAws
            RELEASE loRest
            RELEASE loConnection
            RELEASE loXml
            RELEASE loSeenPages
            RELEASE loMarkerPair
            RELEASE loKeyv
            CANCEL
        ENDIF

        ? "VersionId: " + loXml.GetChildContent("Version[i]|VersionId")
        loTextCompare.Clear()
        loTextCompare.SetString(loXml.GetChildContent("Version[i]|IsLatest"))
        lnSameText8 = loTextCompare.ContentsEqual("",1)
        IF ((loXml.HasChildWithTag("Version[i]|IsLatest") <> 1) OR (lnSameText8 = 1)) THEN
            ? "Missing response field: Version[i]|IsLatest"
            RELEASE loTextCompare
            RELEASE loCredentials
            RELEASE loEndpoint
            RELEASE loAws
            RELEASE loRest
            RELEASE loConnection
            RELEASE loXml
            RELEASE loSeenPages
            RELEASE loMarkerPair
            RELEASE loKeyv
            CANCEL
        ENDIF

        ? "IsLatest: " + loXml.GetChildContent("Version[i]|IsLatest")
        loTextCompare.Clear()
        loTextCompare.SetString(loXml.GetChildContent("Version[i]|LastModified"))
        lnSameText9 = loTextCompare.ContentsEqual("",1)
        IF ((loXml.HasChildWithTag("Version[i]|LastModified") <> 1) OR (lnSameText9 = 1)) THEN
            ? "Missing response field: Version[i]|LastModified"
            RELEASE loTextCompare
            RELEASE loCredentials
            RELEASE loEndpoint
            RELEASE loAws
            RELEASE loRest
            RELEASE loConnection
            RELEASE loXml
            RELEASE loSeenPages
            RELEASE loMarkerPair
            RELEASE loKeyv
            CANCEL
        ENDIF

        ? "LastModified: " + loXml.GetChildContent("Version[i]|LastModified")
        loTextCompare.Clear()
        loTextCompare.SetString(loXml.GetChildContent("Version[i]|Size"))
        lnSameText10 = loTextCompare.ContentsEqual("",1)
        IF ((loXml.HasChildWithTag("Version[i]|Size") <> 1) OR (lnSameText10 = 1)) THEN
            ? "Missing response field: Version[i]|Size"
            RELEASE loTextCompare
            RELEASE loCredentials
            RELEASE loEndpoint
            RELEASE loAws
            RELEASE loRest
            RELEASE loConnection
            RELEASE loXml
            RELEASE loSeenPages
            RELEASE loMarkerPair
            RELEASE loKeyv
            CANCEL
        ENDIF

        ? "Size: " + loXml.GetChildContent("Version[i]|Size")
        loTextCompare.Clear()
        loTextCompare.SetString(loXml.GetChildContent("Version[i]|ETag"))
        lnSameText11 = loTextCompare.ContentsEqual("",1)
        IF ((loXml.HasChildWithTag("Version[i]|ETag") <> 1) OR (lnSameText11 = 1)) THEN
            ? "Missing response field: Version[i]|ETag"
            RELEASE loTextCompare
            RELEASE loCredentials
            RELEASE loEndpoint
            RELEASE loAws
            RELEASE loRest
            RELEASE loConnection
            RELEASE loXml
            RELEASE loSeenPages
            RELEASE loMarkerPair
            RELEASE loKeyv
            CANCEL
        ENDIF

        ? "ETag: " + loXml.GetChildContent("Version[i]|ETag")
        v = v + 1
    ENDDO
    d = 0
    DO WHILE (d < loXml.NumChildrenHavingTag("DeleteMarker"))
        loXml.I = d
        loTextCompare.Clear()
        loTextCompare.SetString(loXml.GetChildContent("DeleteMarker[i]|Key"))
        lnSameText12 = loTextCompare.ContentsEqual("",1)
        IF ((loXml.HasChildWithTag("DeleteMarker[i]|Key") <> 1) OR (lnSameText12 = 1)) THEN
            ? "Missing response field: DeleteMarker[i]|Key"
            RELEASE loTextCompare
            RELEASE loCredentials
            RELEASE loEndpoint
            RELEASE loAws
            RELEASE loRest
            RELEASE loConnection
            RELEASE loXml
            RELEASE loSeenPages
            RELEASE loMarkerPair
            RELEASE loKeyv
            CANCEL
        ENDIF

        loKeyd = CreateObject('Chilkat.StringBuilder')
        lnSuccess = loKeyd.Append(loXml.GetChildContent("DeleteMarker[i]|Key"))
        IF (lnSuccess <> 1) THEN
            ? "Could not prepare the request."
            RELEASE loTextCompare
            RELEASE loCredentials
            RELEASE loEndpoint
            RELEASE loAws
            RELEASE loRest
            RELEASE loConnection
            RELEASE loXml
            RELEASE loSeenPages
            RELEASE loMarkerPair
            RELEASE loKeyv
            RELEASE loKeyd
            CANCEL
        ENDIF

        lnKeydPluses = loKeyd.Replace("+","%2B")
        lnSuccess = loKeyd.Decode("url","utf-8")
        IF (lnSuccess <> 1) THEN
            ? "Could not decode a returned key."
            RELEASE loTextCompare
            RELEASE loCredentials
            RELEASE loEndpoint
            RELEASE loAws
            RELEASE loRest
            RELEASE loConnection
            RELEASE loXml
            RELEASE loSeenPages
            RELEASE loMarkerPair
            RELEASE loKeyv
            RELEASE loKeyd
            CANCEL
        ENDIF

        ? "DeleteMarker key: " + loKeyd.GetAsString()
        loTextCompare.Clear()
        loTextCompare.SetString(loXml.GetChildContent("DeleteMarker[i]|VersionId"))
        lnSameText13 = loTextCompare.ContentsEqual("",1)
        IF ((loXml.HasChildWithTag("DeleteMarker[i]|VersionId") <> 1) OR (lnSameText13 = 1)) THEN
            ? "Missing response field: DeleteMarker[i]|VersionId"
            RELEASE loTextCompare
            RELEASE loCredentials
            RELEASE loEndpoint
            RELEASE loAws
            RELEASE loRest
            RELEASE loConnection
            RELEASE loXml
            RELEASE loSeenPages
            RELEASE loMarkerPair
            RELEASE loKeyv
            RELEASE loKeyd
            CANCEL
        ENDIF

        ? "VersionId: " + loXml.GetChildContent("DeleteMarker[i]|VersionId")
        loTextCompare.Clear()
        loTextCompare.SetString(loXml.GetChildContent("DeleteMarker[i]|IsLatest"))
        lnSameText14 = loTextCompare.ContentsEqual("",1)
        IF ((loXml.HasChildWithTag("DeleteMarker[i]|IsLatest") <> 1) OR (lnSameText14 = 1)) THEN
            ? "Missing response field: DeleteMarker[i]|IsLatest"
            RELEASE loTextCompare
            RELEASE loCredentials
            RELEASE loEndpoint
            RELEASE loAws
            RELEASE loRest
            RELEASE loConnection
            RELEASE loXml
            RELEASE loSeenPages
            RELEASE loMarkerPair
            RELEASE loKeyv
            RELEASE loKeyd
            CANCEL
        ENDIF

        ? "IsLatest: " + loXml.GetChildContent("DeleteMarker[i]|IsLatest")
        loTextCompare.Clear()
        loTextCompare.SetString(loXml.GetChildContent("DeleteMarker[i]|LastModified"))
        lnSameText15 = loTextCompare.ContentsEqual("",1)
        IF ((loXml.HasChildWithTag("DeleteMarker[i]|LastModified") <> 1) OR (lnSameText15 = 1)) THEN
            ? "Missing response field: DeleteMarker[i]|LastModified"
            RELEASE loTextCompare
            RELEASE loCredentials
            RELEASE loEndpoint
            RELEASE loAws
            RELEASE loRest
            RELEASE loConnection
            RELEASE loXml
            RELEASE loSeenPages
            RELEASE loMarkerPair
            RELEASE loKeyv
            RELEASE loKeyd
            CANCEL
        ENDIF

        ? "LastModified: " + loXml.GetChildContent("DeleteMarker[i]|LastModified")
        d = d + 1
    ENDDO
    loTextCompare.Clear()
    loTextCompare.SetString(loXml.GetChildContent("IsTruncated"))
    lnSameText16 = loTextCompare.ContentsEqual("",1)
    IF ((loXml.HasChildWithTag("IsTruncated") <> 1) OR (lnSameText16 = 1)) THEN
        ? "Missing response field: IsTruncated"
        RELEASE loTextCompare
        RELEASE loCredentials
        RELEASE loEndpoint
        RELEASE loAws
        RELEASE loRest
        RELEASE loConnection
        RELEASE loXml
        RELEASE loSeenPages
        RELEASE loMarkerPair
        RELEASE loKeyv
        RELEASE loKeyd
        CANCEL
    ENDIF

    loTextCompare.Clear()
    loTextCompare.SetString(loXml.GetChildContent("IsTruncated"))
    lnSameText17 = loTextCompare.ContentsEqual("true",1)
    loTextCompare.Clear()
    loTextCompare.SetString(loXml.GetChildContent("IsTruncated"))
    lnSameText18 = loTextCompare.ContentsEqual("false",1)
    IF ((lnSameText17 <> 1) AND (lnSameText18 <> 1)) THEN
        ? "Invalid IsTruncated value."
        RELEASE loTextCompare
        RELEASE loCredentials
        RELEASE loEndpoint
        RELEASE loAws
        RELEASE loRest
        RELEASE loConnection
        RELEASE loXml
        RELEASE loSeenPages
        RELEASE loMarkerPair
        RELEASE loKeyv
        RELEASE loKeyd
        CANCEL
    ENDIF

    lnMore = 0
    loTextCompare.Clear()
    loTextCompare.SetString(loXml.GetChildContent("IsTruncated"))
    lnSameText19 = loTextCompare.ContentsEqual("true",1)
    IF (lnSameText19 = 1) THEN
        loTextCompare.Clear()
        loTextCompare.SetString(loXml.GetChildContent("NextKeyMarker"))
        lnSameText20 = loTextCompare.ContentsEqual("",1)
        IF ((loXml.HasChildWithTag("NextKeyMarker") <> 1) OR (lnSameText20 = 1)) THEN
            ? "Missing response field: NextKeyMarker"
            RELEASE loTextCompare
            RELEASE loCredentials
            RELEASE loEndpoint
            RELEASE loAws
            RELEASE loRest
            RELEASE loConnection
            RELEASE loXml
            RELEASE loSeenPages
            RELEASE loMarkerPair
            RELEASE loKeyv
            RELEASE loKeyd
            CANCEL
        ENDIF

        loTextCompare.Clear()
        loTextCompare.SetString(loXml.GetChildContent("NextVersionIdMarker"))
        lnSameText21 = loTextCompare.ContentsEqual("",1)
        IF ((loXml.HasChildWithTag("NextVersionIdMarker") <> 1) OR (lnSameText21 = 1)) THEN
            ? "Missing response field: NextVersionIdMarker"
            RELEASE loTextCompare
            RELEASE loCredentials
            RELEASE loEndpoint
            RELEASE loAws
            RELEASE loRest
            RELEASE loConnection
            RELEASE loXml
            RELEASE loSeenPages
            RELEASE loMarkerPair
            RELEASE loKeyv
            RELEASE loKeyd
            CANCEL
        ENDIF

        loNextKey = CreateObject('Chilkat.StringBuilder')
        lnSuccess = loNextKey.Append(loXml.GetChildContent("NextKeyMarker"))
        IF (lnSuccess <> 1) THEN
            ? "Could not prepare the request."
            RELEASE loTextCompare
            RELEASE loCredentials
            RELEASE loEndpoint
            RELEASE loAws
            RELEASE loRest
            RELEASE loConnection
            RELEASE loXml
            RELEASE loSeenPages
            RELEASE loMarkerPair
            RELEASE loKeyv
            RELEASE loKeyd
            RELEASE loNextKey
            CANCEL
        ENDIF

        lnNextKeyPluses = loNextKey.Replace("+","%2B")
        lnSuccess = loNextKey.Decode("url","utf-8")
        IF (lnSuccess <> 1) THEN
            ? "Could not decode a returned key."
            RELEASE loTextCompare
            RELEASE loCredentials
            RELEASE loEndpoint
            RELEASE loAws
            RELEASE loRest
            RELEASE loConnection
            RELEASE loXml
            RELEASE loSeenPages
            RELEASE loMarkerPair
            RELEASE loKeyv
            RELEASE loKeyd
            RELEASE loNextKey
            CANCEL
        ENDIF

        lnSuccess = loMarkerPair.UpdateString("key",loNextKey.GetAsString())
        IF (lnSuccess <> 1) THEN
            ? "Could not build saved state."
            RELEASE loTextCompare
            RELEASE loCredentials
            RELEASE loEndpoint
            RELEASE loAws
            RELEASE loRest
            RELEASE loConnection
            RELEASE loXml
            RELEASE loSeenPages
            RELEASE loMarkerPair
            RELEASE loKeyv
            RELEASE loKeyd
            RELEASE loNextKey
            CANCEL
        ENDIF

        lnSuccess = loMarkerPair.UpdateString("id",loXml.GetChildContent("NextVersionIdMarker"))
        IF (lnSuccess <> 1) THEN
            ? "Could not build saved state."
            RELEASE loTextCompare
            RELEASE loCredentials
            RELEASE loEndpoint
            RELEASE loAws
            RELEASE loRest
            RELEASE loConnection
            RELEASE loXml
            RELEASE loSeenPages
            RELEASE loMarkerPair
            RELEASE loKeyv
            RELEASE loKeyd
            RELEASE loNextKey
            CANCEL
        ENDIF

        lcPair = loMarkerPair.Emit()
        IF (loSeenPages.Contains(lcPair) = 1) THEN
            ? "Repeated marker pair; enumeration is incomplete."
            RELEASE loTextCompare
            RELEASE loCredentials
            RELEASE loEndpoint
            RELEASE loAws
            RELEASE loRest
            RELEASE loConnection
            RELEASE loXml
            RELEASE loSeenPages
            RELEASE loMarkerPair
            RELEASE loKeyv
            RELEASE loKeyd
            RELEASE loNextKey
            CANCEL
        ENDIF

        lnSuccess = loSeenPages.AddInt(lcPair,1)
        IF (lnSuccess <> 1) THEN
            ? "Could not prepare the request."
            RELEASE loTextCompare
            RELEASE loCredentials
            RELEASE loEndpoint
            RELEASE loAws
            RELEASE loRest
            RELEASE loConnection
            RELEASE loXml
            RELEASE loSeenPages
            RELEASE loMarkerPair
            RELEASE loKeyv
            RELEASE loKeyd
            RELEASE loNextKey
            CANCEL
        ENDIF

        IF (lnPage > 0) THEN
            lnSuccess = loRest.RemoveQueryParam("key-marker")
            IF (lnSuccess <> 1) THEN
                ? "Could not prepare the request."
                RELEASE loTextCompare
                RELEASE loCredentials
                RELEASE loEndpoint
                RELEASE loAws
                RELEASE loRest
                RELEASE loConnection
                RELEASE loXml
                RELEASE loSeenPages
                RELEASE loMarkerPair
                RELEASE loKeyv
                RELEASE loKeyd
                RELEASE loNextKey
                CANCEL
            ENDIF

            lnSuccess = loRest.RemoveQueryParam("version-id-marker")
            IF (lnSuccess <> 1) THEN
                ? "Could not prepare the request."
                RELEASE loTextCompare
                RELEASE loCredentials
                RELEASE loEndpoint
                RELEASE loAws
                RELEASE loRest
                RELEASE loConnection
                RELEASE loXml
                RELEASE loSeenPages
                RELEASE loMarkerPair
                RELEASE loKeyv
                RELEASE loKeyd
                RELEASE loNextKey
                CANCEL
            ENDIF

        ENDIF

        *  AddQueryParam encodes the decoded key and the opaque, unmodified ID once.
        lnSuccess = loRest.AddQueryParam("key-marker",loNextKey.GetAsString())
        IF (lnSuccess <> 1) THEN
            ? "Could not prepare the request."
            RELEASE loTextCompare
            RELEASE loCredentials
            RELEASE loEndpoint
            RELEASE loAws
            RELEASE loRest
            RELEASE loConnection
            RELEASE loXml
            RELEASE loSeenPages
            RELEASE loMarkerPair
            RELEASE loKeyv
            RELEASE loKeyd
            RELEASE loNextKey
            CANCEL
        ENDIF

        lnSuccess = loRest.AddQueryParam("version-id-marker",loXml.GetChildContent("NextVersionIdMarker"))
        IF (lnSuccess <> 1) THEN
            ? "Could not prepare the request."
            RELEASE loTextCompare
            RELEASE loCredentials
            RELEASE loEndpoint
            RELEASE loAws
            RELEASE loRest
            RELEASE loConnection
            RELEASE loXml
            RELEASE loSeenPages
            RELEASE loMarkerPair
            RELEASE loKeyv
            RELEASE loKeyd
            RELEASE loNextKey
            CANCEL
        ENDIF

        lnMore = 1
    ENDIF

    lnPage = lnPage + 1
ENDDO
? "Enumeration complete."

RELEASE loTextCompare
RELEASE loCredentials
RELEASE loEndpoint
RELEASE loAws
RELEASE loRest
RELEASE loConnection
RELEASE loXml
RELEASE loSeenPages
RELEASE loMarkerPair
RELEASE loKeyv
RELEASE loKeyd
RELEASE loNextKey