azure-blob-storageazure-storage

ADLS Rest API - Getting directory list using a SAS token from directory not container?


I am hoping you can help me with I am doing wrong while trying to access an ADLS directory via a SAS token that was specifically created for that SAS token (directory token, not container token).

Url: https://testingsastk.dfs.core.windows.net/testcontainer/testfolder/

I have been following the rest API documentation here and I have created the request using postman.

Postman request

https://{{accountName}}.{{dnsSuffix}}/{{filesystem}}?directory={{directory}}&recursive=true&resource=filesystem&{{sas_token}}

This request get a result that says I am missing a required parameter

missing parameter, directory SAS

However when I switch the SAS Token to a container SAS token the request works fine

https://{{accountName}}.{{dnsSuffix}}/{{filesystem}}?directory={{directory}}&recursive=true&resource=filesystem&{{sas_token_container}}

working request with container SAS


Solution

  • "code": "MissingRequiredQueryParameter", "message": "A query parameter that's mandatory for this request is not specified. \nRequestId:e434310e-e01f-0033-597e-e21b1c000000\nTime:2024-07-30T12:46:42.0903704Z"

    The above error occurs when required query parameter was not specified for this request.

    In my environment, I created SAS token from directory level through portal with rl(read and list) permission.

    Portal:

    enter image description here

    I followed the same MS-Document to get the list of files from specific directory.

    Request:

    GET https://<storage account name>.dfs.core.windows.net/<filesystem name>?directory=<directory name>&recursive=true&resource=filesystem&sp=rl&st=2024-07-31T07:44:10Z&se=2024-07-31T15:44:10Z&spr=https&sv=2022-11-02&sr=d&sig=8uPG8VD4lusVnx8srtr7S0yzzzzzzzz1
    

    The above provided URL with directory sas token, it executed and list the files from specific directory through postman.

    Output:

    enter image description here

    {
        "paths": [
            {
                "contentLength": "4516",
                "creationTime": "1336zzzz62520",
                "etag": "0x8Dzzzz1238",
                "expiryTime": "0",
                "group": "$superuser",
                "lastModified": "Fri, 26 Jul 2024 06:24:08 GMT",
                "name": "sample-directory/22-07-2024 (1).html",
                "owner": "$superuser",
                "permissions": "rw-r-----"
            },
            {
                "contentLength": "1903",
                "creationTime": "1336zzz77725788",
                "etag": "0x8DCADzz005C",
                "expiryTime": "0",
                "group": "$superuser",
                "lastModified": "Fri, 26 Jul 2024 06:24:07 GMT",
                "name": "sample-directory/22-07-2024.html",
                "owner": "$superuser",
                "permissions": "rw-r-----"
            },
            {
                "contentLength": "1923",
                "creationTime": "13366zz6477056276",
                "etag": "0x8DCzzzE03C914",
                "expiryTime": "0",
                "group": "$superuser",
                "lastModified": "Fri, 26 Jul 2024 06:24:07 GMT",
                "name": "sample-directory/24-07-2024.html",
                "owner": "$superuser",
                "permissions": "rw-r-----"
            },
            {
                "contentLength": "18425",
                "creationTime": "133664486476388104",
                "etag": "0x8DCAD3B8DF99708",
                "expiryTime": "0",
                "group": "$superuser",
                "lastModified": "Fri, 26 Jul 2024 06:24:07 GMT",
                "name": "sample-directory/25-07-2024 (1).html",
                "owner": "$superuser",
                "permissions": "rw-r-----"
            },
            {
                "contentLength": "11204",
                "creationTime": "133zz6476337656",
                "etag": "0x8DCzzzDF8D1F8",
                "expiryTime": "0",
                "group": "$superuser",
                "lastModified": "Fri, 26 Jul 2024 06:24:07 GMT",
                "name": "sample-directory/25-07-2024.html",
                "owner": "$superuser",
                "permissions": "rw-r-----"
            },
            {
                "contentLength": "9631",
                "creationTime": "1336zz367948",
                "etag": "0x8DCzDF94z84C",
                "expiryTime": "0",
                "group": "$superuser",
                "lastModified": "Fri, 26 Jul 2024 06:24:07 GMT",
                "name": "sample-directory/26-07-2024.html",
                "owner": "$superuser",
                "permissions": "rw-r-----"
            },
            {
                "contentLength": "0",
                "creationTime": "1336zzz193661964",
                "etag": "0x8DCzzzFAE01BD68",
                "expiryTime": "0",
                "group": "$superuser",
                "isDirectory": "true",
                "lastModified": "Fri, 26 Jul 2024 06:53:39 GMT",
                "name": "sample-directory/test1",
                "owner": "$superuser",
                "permissions": "rwxr-x---"
            },
            {
                "contentLength": "4516",
                "creationTime": "133zzz93873524",
                "etag": "0x8DCAzzzzFAE04F674",
                "expiryTime": "0",
                "group": "$superuser",
                "lastModified": "Fri, 26 Jul 2024 06:53:39 GMT",
                "name": "sample-directory/test1/22-07-2024 (1).html",
                "owner": "$superuser",
                "permissions": "rw-r-----"
            },
            {
                "contentLength": "1903",
                "creationTime": "133664zz3977008",
                "etag": "0x8DCAzzE068AB0",
                "expiryTime": "0",
                "group": "$superuser",
                "lastModified": "Fri, 26 Jul 2024 06:53:39 GMT",
                "name": "sample-directory/test1/22-07-2024.html",
                "owner": "$superuser",
                "permissions": "rw-r-----"
            },
            {
                "contentLength": "1923",
                "creationTime": "13366zz99374548",
                "etag": "0x8DCzzzAE58E6D4",
                "expiryTime": "0",
                "group": "$superuser",
                "lastModified": "Fri, 26 Jul 2024 06:53:39 GMT",
                "name": "sample-directory/test1/24-07-2024.html",
                "owner": "$superuser",
                "permissions": "rw-r-----"
            },
            {
                "contentLength": "18425",
                "creationTime": "1336zzz93776276",
                "etag": "0x8zzFAE037A94",
                "expiryTime": "0",
                "group": "$superuser",
                "lastModified": "Fri, 26 Jul 2024 06:53:39 GMT",
                "name": "sample-directory/test1/25-07-2024 (1).html",
                "owner": "$superuser",
                "permissions": "rw-r-----"
            },
            {
                "contentLength": "11204",
                "creationTime": "1336zzz4199196200",
                "etag": "0x8DzzzAE562E28",
                "expiryTime": "0",
                "group": "$superuser",
                "lastModified": "Fri, 26 Jul 2024 06:53:39 GMT",
                "name": "sample-directory/test1/25-07-2024.html",
                "owner": "$superuser",
                "permissions": "rw-r-----"
            },
            {
                "contentLength": "9631",
                "creationTime": "133664zz7472",
                "etag": "0x8DCzzAE037F40",
                "expiryTime": "0",
                "group": "$superuser",
                "lastModified": "Fri, 26 Jul 2024 06:53:39 GMT",
                "name": "sample-directory/test1/26-07-2024.html",
                "owner": "$superuser",
                "permissions": "rw-r-----"
            }
        ]
    }