[SOLVED] Azure Blob List “Value for one of the query parameters specified in the request URI is invalid” when using API Management service


This Content is from Stack Overflow. Question asked by Damo

I’m using API Management service to make a simple interface between a c# desktop application and a Azure Blob storage account.

API Management service is providing the authentication via a Subscription Key. This works fine for downloading blobs.

I also want to list the contents of an individual container / folder (prefix) using the same method.

I’ve tested the following HTTP call outside the API Management service, it works correctly.


When I use this in API Management service, I’m returned an error:

    <Message>Value for one of the query parameters specified in the request URI is invalid.
    <Reason />

My processing rules:

        <base />          
        <set-header name="Ocp-Apim-Subscription-Key" exists-action="delete" />
        <set-header name="Sec-Fetch-Site" exists-action="delete" />
        <set-header name="Sec-Fetch-Mode" exists-action="delete" />
        <set-header name="Sec-Fetch-Dest" exists-action="delete" />
        <set-header name="Accept" exists-action="delete" />
        <set-header name="Accept-Encoding" exists-action="delete" />
        <set-header name="Referer" exists-action="delete" />
        <set-header name="X-Forwarded-For" exists-action="delete" />
        <set-header name="x-ms-version" exists-action="override">
            <value>@{string version = "2017-11-09"; return version;}</value>
        <set-backend-service base-url="@{
return String.Format("https://<storageaccount>.blob.core.windows.net/files?restype=directory&comp=list&prefix=globalpackages/1.0");
}" />
        <authentication-managed-identity resource="https://storage.azure.com/" />
        <base />
        <base />
        <base />

what am I doing wrong?


Based on the documentation available here, the query parameter should be restype=container instead of restype=directory if you need to list blobs inside a blob container.

Once you make this change, you should be able to list the blobs.

Answered by Gaurav Mantri, Content is distributed under the terms of CC BY-SA 4.0.

people found this article helpful. What about you?