6

I'm trying to query Azure query blob content through REST API, following the documentation below

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

I made my blob contents public for testing and a GET request to blob URI is giving the content, but making a post request to mentioned URI

https://myaccount.blob.core.windows.net/mycontainer/myblob?comp=query (replaced myaccount, mycontainer and myblob)

giving me following error

<?xml version="1.0" encoding="utf-8"?>
<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

0

1 Answer 1

5

I think you might use the SharedKey for authentication when using Query Blob Contents rest api.

If it's the case, you'd better add the steps or code about how do you build the Authorization header. There might be a minor error there.

I give it a try by using sas token for authentication(you can refer to this link for how to generate sas token via azure portal or code), and it can work well.

Here is my request url:

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

And in postman, the request headers are as below:

enter image description here

the request body is as below:

enter image description here

And as you can see the test results in the above screenshots, the status code is 200, and we can get the expected blob content.

Sign up to request clarification or add additional context in comments.

7 Comments

After adding SAS Token I got this error solved, Thanks for your help. but now it is showing. A required feature for this operation is not enabled on the account, BlobQuery. I searched for an option like this in Azure and not able to find it. How to enable this feature in my account?
@ASHMILHUSSAINK, what's your azure storage? general purpose v2 or others? are you querying a .json/.csv file or other types of file?
@Ican Yang, Storage is StorageV2 (general purpose v2) I have tried with Both .json and .csv
@ASHMILHUSSAINK the file is block blob type?
Yes the file is Block blob
|

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.