【问题标题】:InvalidQueryParameterValue in Query Blob Contents using REST API使用 REST API 查询 Blob 内容中的 InvalidQueryParameterValue
【发布时间】:2021-05-07 11:53:39
【问题描述】:

我正在尝试按照以下文档通过 REST API 查询 Azure 查询 blob 内容

https://docs.microsoft.com/en-us/rest/api/storageservices/query-blob-contents

我公开了我的 blob 内容以供测试,并且对 blob URI 的 GET 请求正在提供内容,但对提到的 URI 发出了发布请求

https://myaccount.blob.core.windows.net/mycontainer/myblob?comp=query (替换了 myaccount、mycontainer 和 myblob)

以下错误提示我

<Error>
    <Code>InvalidQueryParameterValue</Code>
    <Message>Value for one of the query parameters specified in the request URI is invalid.
RequestId:1c52fc4f-801e-0061-63fc-f98163000000
Time:2021-02-03T07:15:32.9547540Z</Message>
    <QueryParameterName>comp</QueryParameterName>
    <QueryParameterValue>query</QueryParameterValue>
    <Reason />
</Error>```

blob content is JSON and Blob is a Block Blob type
 

【问题讨论】:

    标签: azure blob azure-blob-storage azure-rest-api


    【解决方案1】:

    我想你在使用Query Blob Contents rest api时可能会使用SharedKey for authentication

    如果是这种情况,您最好添加有关如何构建Authorization header 的步骤或代码。那里可能有一个小错误。

    我尝试使用sas token进行身份验证(如何通过azure门户或代码生成sas token可以参考this link),效果很好。

    这是我的请求网址:

    https://yy1.blob.core.windows.net/a11/my11.csv?comp=query&my_sas_token
    

    在邮递员中,request headers 如下:

    request body 如下:

    如你在上面的截图中看到的测试结果,状态码是200,我们可以得到预期的blob内容。

    【讨论】:

    • 添加 SAS 令牌后,我解决了这个错误,感谢您的帮助。但现在它正在显示。帐户 BlobQuery 未启用此操作所需的功能。我在 Azure 中搜索了这样的选项,但找不到。如何在我的帐户中启用此功能?
    • @ASHMILHUSSAINK,你的天蓝色存储是什么?通用v2或其他?您是在查询 .json/.csv 文件还是其他类型的文件?
    • @Ican Yang,存储是 StorageV2(通用 v2)我已经尝试过 .json 和 .csv
    • @ASHMILHUSSAINK 文件是block blob type?
    • 是的文件是块 blob
    猜你喜欢
    • 1970-01-01
    • 2019-08-10
    • 2015-04-23
    • 2012-12-14
    • 2015-12-19
    • 2018-10-16
    • 2014-09-17
    • 2013-09-21
    • 2011-01-12
    相关资源
    最近更新 更多