Azure file storage issue:The value for one of the HTTP headers is not in the correct format

Adrian Khoshbin 0 Reputation points
2024-05-22T05:57:53.7666667+00:00

Dear Colleagues,

I have created uploaded multiple files under file share . when I want each file using the hyperlink provided for the file. I get below error: Please guide me , what I should do to be able to see each file via browser.

thanks

Azure Files
Azure Files
An Azure service that offers file shares in the cloud.
1,200 questions
Azure Storage Explorer
Azure Storage Explorer
An Azure tool that is used to manage cloud storage resources on Windows, macOS, and Linux.
238 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.
2,821 questions
Azure Blob Storage
Azure Blob Storage
An Azure service that stores unstructured data in the cloud as blobs.
2,547 questions
0 comments No comments
{count} votes

2 answers

Sort by: Most helpful
  1. Binath Banula 0 Reputation points
    2024-05-22T06:48:03.1466667+00:00
    1. Check the HTTP Headers: Ensure that the x-ms-version header is correctly set in your request. This header should specify a valid version of the Azure Storage service API.
    2. Set a Valid x-ms-version Header: If the x-ms-version header is missing or empty, you need to set it to a valid version. For example, you can set it to 2020-08-04:
         x-ms-version: 2020-08-04
      
    3. Verify the Hyperlink Format: Ensure that the hyperlinks you are using to access the files are correctly formatted and include the necessary query parameters, if any.
    4. Use a REST Client or Browser Developer Tools: You can use a REST client (such as Postman) or the developer tools in your browser to inspect the HTTP request headers and ensure that the x-ms-version header is correctly included and set.
    5. Check for Any Required Authentication: Ensure that the request includes any necessary authentication headers, such as the Authorization header. If you are using Shared Access Signatures (SAS), make sure that the SAS token is correctly included in the URL.

    Example of Correct HTTP Request

    Here is an example of an HTTP request to access a file in Azure Storage with the x-ms-version header set correctly:

    GET https:
    

    Programmatic Approach

    If you are making the request programmatically, ensure that your code sets the x-ms-version header correctly. Here is an example in Python using the requests library:

    import requests
    
    url = "https://<your-storage-account>.file.core.windows.net/<your-file-share>/<your-file-path>"
    headers = {
        "x-ms-version": "2020-08-04",
        "Authorization": "Bearer <your-access-token>"
    }
    
    response = requests.get(url, headers=headers)
    if response.status_code == 200:
        print("File accessed successfully")
    else:
        print(f"Error: {response.status_code} - {response.text}")
    

    Final steps

    Once you have verified and set the correct x-ms-version header, try accessing the file again via the hyperlink. If you continue to experience issues, provide details!! GG

    0 comments No comments

  2. Nehruji R 3,726 Reputation points Microsoft Vendor
    2024-05-23T06:42:49.89+00:00

    Hello Adrian Khoshbin,

    Greetings! Welcome to Microsoft Q&A Platform.

    Adding to above information. The error message “The value for one of the HTTP headers is not in the correct format” can occur due to one or more of the HTTP headers you are sending to the file storage service are not formatted correctly.

    There can be several methods for troubleshooting

    Check to ensure that the Date or x-ms-date header is correctly formatted. The format should be in RFC 1123 format: Day, dd MMM yyyy HH:mm:ss GMT.

    When setting metadata for a storage resource, each metadata name-value pair must adhere to certain naming restrictions. The metadata header name must start with prefix x-ms-meta-. The header value should not contain control characters.

    Check if the Content-Length header accurately reflects the size of the payload being sent. If the size is incorrect, it can cause errors.

    Check if the Content-Type and Content-Encoding headers are correct for the data you are sending. For example, if you're sending JSON data, your Content-Type should be application/json.

    Remove the accessTier Property: If you’re deploying a file share using an ARM template, make sure to remove the accessTier property. The default value for this property is TransactionOptimized. Although the template exported from the Azure portal includes this property, deployment fails if it’s present. Removing it should resolve the issue

    Check Storage Account Kind and SKU: If you’re using a premium storage account, ensure that the accessTier value is compatible with the storage account kind and SKU. For example, the ‘TransactionOptimized’ access tier is available for storage account kind ‘StorageV2’ and SKU 'Standard_LRS’

    Hope this answer helps! Please let us know if you have any further queries. I’m happy to assist you further.


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

    0 comments No comments