Microsoft Azure File share
How use POSTMAN to send up a file to AZURE file store with REST API?
Download POSTMAN program from https://www.postman.com/downloads/
Go into your AZURE subscription and to your storage account, to get the shared access signature (SAS), that is a URI that grants restricted access rights to Azure Storage resources.
As this is a file share you should select allowed service to be FILE, and allowed resource types to be OBJECT.
Set the end date for expiry to a year from now.
Leave the Allowed IP addresses blank – to allow any computer to access the account. (Keep the DNS and FIREWALL setup so that only computers from your company can reach the azure area).
Allowed protocols should be HTTPS only.
Click on Generate SAS and connection string. This strings you must copy and save in notepad. You can not show them again when you have left this Azure page.
The connection string contain all info you need. Inside notepad split it up to only have the information you need in one string for file share. Copy text after FileEndpoint=.
You should get something like this:
sv= is the version of REST API, the value you may need to add as; x-ms-version: 2022-11-02
se= is the end date for the connection key to work, like 2025-07-31T22:45:45Z
st= is the start date for the connection key to work, like 2023-05-30T14:45:45Z
sig= is the key value, that gives you full access to the area. Do not share it with others.
sp= is what kind of rights you have given, e.g. read write delete list create.
In your storage account file share, you may have created some subfolders like testfiles. Click on File Shares to find the name and any sub-folders you have underneath it. Click on file share and click on browse to find the folder name where you have Authentication method: Access key. This is the folder you can access.
Update your url to contain the path and the filename of the file you want to create. Like https://xyz.file.core.windows.net/testfiles/test.txt?sv=2022-11-02……
Start POSTMAN. Do not login, skip that. Create a New HTTP dialog.
Select PUT and paste in your URL. Then POSTMAN will interpreter your values and list them as parameters.
With file share, you must do the REST API in two steps. First create the file in correct size, and then do a second call to fill the file with data. This is different from BLOB storage, where you can do it in one REST API CALL.
In POSTMAN go to the Headers tab and add two keys:
x-ms-type = file x-ms-content-length = 1
Here we set the length of the file to 1 character (1 byte). (this will work as long you only use a-z characters and UTF-8 coding).
Click on SEND button, and if all is correct you should get: 201 created.
Browse to you AZURE file storage and check that the file was created, with a size of 1.
To write to the file, add in headers this two keys:
x-ms-write = update x-ms-range = bytes=0-0
The x-ms-range should always start with 0 and then be one number less than the total of characters in your file. If the file is 42 characters, then the value should be bytes=0-41.
Important, in the params tab you must add a key as below (this to active the range function – otherwise the x-ms-range is not used);
comp = range
Then we need to add some data in POSTMAN to write to the file, go to the Body tab, and select RAW – text and enter a letter.
The text should be the same size as the file you have created. File size and text you put into the file must match exactly on the byte.
Click on SEND, and you should get a Status: 201 Created if all is fine.
Common errors you can see in POSTMAN are:
Server failed to authenticate the request. Make sure the value of Authorization header is formed correctly including the signature. Authentication scheme Bearer for files is not supported in this version.
This is solved by adding the correct version, like: x-ms-version: 2022-11-02
You should also try to have headers like:
<Error><Code>UnsupportedHttpVerb</Code><Message>The resource doesn't support specified Http Verb.
This is solved by using PUT instead of POST.
<Error><Code>ShareNotFound</Code><Message>The specified share does not exist.
This is solved by you enter the correct path and filename to the URL.
HTTP Error 400. The request host name is invalid.
Solved by enter the correct host.
Solved by enter the header Content-Length.
One of the HTTP headers specified in the request is not supported. <HeaderName>x-ms-range</HeaderName>
Solved by adding the key comp in params tab.
An HTTP header that's mandatory for this request is not specified. <HeaderName>x-ms-content-length</HeaderName>
Solved by adding the key x-ms-content-length.
An HTTP header that's mandatory for this request is not specified. <HeaderName>x-ms-write</HeaderName>
Solved by adding the key x-ms-write.
The value for one of the HTTP headers is not in the correct format. <HeaderName>Content-Length</HeaderName> <HeaderValue>1</HeaderValue>