Storage Gen2 API in Postman

Shiv Khullar 1 Reputation point
2020-12-23T23:58:09.51+00:00

Hi ,

I am new to Azure Portal and would like to use the Azure Gen2 API to create the files on storage.

I have been able to generate the access token in Postman -

https://login.microsoftonline.com/\<tenant id>/oauth2/v2.0/token

I now have access token to be used.

Now I call -

https://storageaccountshiv.dfs.core.windows.net/blue?resource=filesystem

Headers passed are -

Authorization : Bearer {access token}
x-ms-version : 2020-12-23
Content-Length : 0

But complains
{
"error": {
"code": "InvalidHeaderValue",
"message": "The value for one of the HTTP headers is not in the correct format.\nRequestId:34111c9a-d01f-0004-1787-d9cf50000000\nTime:2020-12-23T23:55:50.5175280Z"
}
}

I went through some posts and it says this is what we need to pass. Any idea what could be missing here.

This should create a folder under "Blob Containers".. Correct?

Thanks in advance.

Thanks,
Shiv

Azure Storage Explorer
Azure Storage Explorer
An Azure tool that is used to manage cloud storage resources on Windows, macOS, and Linux.
266 questions
Azure Storage Accounts
Azure Storage Accounts
Globally unique resources that provide access to data management services and serve as the parent namespace for the services.
3,225 questions
Azure Role-based access control
Azure Role-based access control
An Azure service that provides fine-grained access management for Azure resources, enabling you to grant users only the rights they need to perform their jobs.
830 questions
0 comments No comments
{count} votes

10 answers

Sort by: Most helpful
  1. SUN TEIK HENG @ SAN TEIK HENG 1 Reputation point
    2020-12-30T19:09:16.603+00:00

    In Azure portal, generate the "Shared Access Signature".

    Paste the File service SAS URL into Postman to create the file "abc.txt"

    https://storageaccountshiv.dfs.core.windows.net/blue/abc.txt?sv=2019-12-12&ss=bfqt&srt=sco&sp=rwdlacupx&se=2020-12-31T02:36:19Z&st=2020-12-30T18:36:19Z&spr=https&sig=qbX6rmPtzQzc%3BKldZwf9sR98a7UWLOiy0RFUZj6KK6U%3D

    Note:
    In this example, select everything in "Allowed services", "Allowed resource types", "Allowed permissions" and "Blob versioning permissions"

    52240-sas.png

    0 comments No comments

  2. Shiv Khullar 1 Reputation point
    2020-12-30T19:42:40.267+00:00

    I created a container "shiv" through Azure portal and now using API want to add a file in this container.

    Copied File Service SAS URL and added /shiv/abc.txt

    https://storageaccountshiv.file.core.windows.net/shiv/abc.txt?sv=2019-12-12&ss=bfqt&srt=sco&sp=rwdlacupx&se=2020-12-31T03:33:47Z&st=2020-12-30T19:33:47Z&spr=https&sig=YBJW3pYdL1t0qnqfYb58tvyK8i2tDDSyOJeMgWwGXY%3D

    52295-image.png

    Response is -

    52361-image.png

    0 comments No comments

  3. SUN TEIK HENG @ SAN TEIK HENG 1 Reputation point
    2020-12-31T01:22:49.837+00:00

    Hi @Shiv Khullar ,

    Please follow the following steps to create the container called "shiv2":

    Step 1) Create Create a storage account to use with Azure Data Lake Storage Gen2, https://learn.microsoft.com/en-us/azure/storage/blobs/create-data-lake-storage-account

    Step 2) Generate SAS

    52391-generatesas.png

    (Note: Use the Blob Service URL)

    Step 3) Test with Postman

    52289-testwithpostman.png

    (Note: Set the header, x-ms-blob-type: BlockBlob)

    Step 4) Examine "Data Lake Storage" in Azure portal that the container "shiv2" has been created successfully.

    52290-examinedatalakestorage.png

    0 comments No comments

  4. Shiv Khullar 1 Reputation point
    2020-12-31T15:00:51.183+00:00

    Hi TeikHengSun-1687,

    Thanks a lot for sharing the detailed steps.. I feel these steps are missing in the documentation.

    Create container worked like a charm.

    I have two more questions -

    1. Can you pls send me postman request to create a file under the container. What would be the filesystem and restype and if any header needs to be added.
    2. I would like to try the same create container and create file under the container with oAuth2.0 authentication. Was not successful in doing that.
      I am able to generate the oAuth2.0 accesstoken but when I try to use it to create the container , it doesnt work.

    Thank you so much for your support.

    Thanks,
    Shiv

    0 comments No comments

  5. Sumarigo-MSFT 47,021 Reputation points Microsoft Employee
    2021-03-05T12:32:26.663+00:00

    @Shiv Khullar Updating the thread after the issue is been fixed , this can be beneficial to other community members who is facing the similar issue.

    Proper parameters and syntax for Postman,
    The documentation which we are following: Put Blob (REST API) - Azure Storage | Microsoft Learn
    PUT: https://<storageaccount>.blob.core.windows.net/<container>

    Include Headers:

    Authorization - REQUIRED
    X-ms-date = ‘Tue, 05 Jan hh:mm:ss GMT - REQUIRED
    X-ms-version = 2020-02-10 – REQUIRED
    Content-Length = 0 - REQUIRED

    ------------------------------------------------------------------------------------------------------------------------------------------------

    Please don’t forget to "Accept the answer” and “up-vote” wherever the information provided helps you, this can be beneficial to other community members.

    0 comments No comments

Your answer

Answers can be marked as Accepted Answers by the question author, which helps users to know the answer solved the author's problem.