locked
{"The remote server returned an error: (403) Forbidden."} RRS feed

  • Question

  • While downloading the blobstream I am getting an error 

    {"The remote server returned an error: (403) Forbidden."}

    with HttpStatusMessage as 

    "Server failed to authenticate the request. Make sure the value of Authorization header is formed correctly including the signature."

    I am using the following 

    // Retrieve storage account from connection string.
    CloudStorageAccount storageAccount = CloudStorageAccount.Parse(
        CloudConfigurationManager.GetSetting("StorageConnectionString"));
    
    // Create the blob client.
    CloudBlobClient blobClient = storageAccount.CreateCloudBlobClient();
    
    // Retrieve reference to a previously created container.
    CloudBlobContainer container = blobClient.GetContainerReference("mycontainer");
    
    // Retrieve reference to a blob named "myblob.txt"
    CloudBlockBlob blockBlob2 = container.GetBlockBlobReference("myblob.txt");
    
    string text;
    using (var memoryStream = new MemoryStream())
    {
        blockBlob2.DownloadToStream(memoryStream);
        text = System.Text.Encoding.UTF8.GetString(memoryStream.ToArray());
    }

    and getting this error at blockBlob2.DownloadToStream(memoryStream).


    Mark Answered, if it solves your question and Vote if you found it helpful.
    Rohit Arora

    Wednesday, February 26, 2014 8:39 AM

Answers

  • I used  
    blockBlob2.DownloadText();
    and it worked for me

    Mark Answered, if it solves your question and Vote if you found it helpful.
    Rohit Arora

    • Marked as answer by RohitArora Thursday, February 27, 2014 10:35 AM
    Thursday, February 27, 2014 10:35 AM

All replies

  • Is StorageConnectionString a Shared Access Signature token or an account name/key combination? If the former, please make sure the token is still valid at the time the blob is downloaded. If the latter, please make sure you are using the correct account name/key combination.

    If you are still receiving this error after verifying these, please make sure you are using HTTPS instead of HTTP.

    Thursday, February 27, 2014 1:35 AM
  • Hi,

    In addition, Please make sure your container name and blob name are right and the file (myblob.txt) is existed. If their names are wrong or file is not existed, you also get the 403 error at "DownloadToStream" method.

    Please check it.

    Will


    We are trying to better understand customer views on social support experience, so your participation in this interview project would be greatly appreciated if you have time. Thanks for helping make community forums a great place.
    Click HERE to participate the survey.

    Thursday, February 27, 2014 2:37 AM
  • I used  
    blockBlob2.DownloadText();
    and it worked for me

    Mark Answered, if it solves your question and Vote if you found it helpful.
    Rohit Arora

    • Marked as answer by RohitArora Thursday, February 27, 2014 10:35 AM
    Thursday, February 27, 2014 10:35 AM
  • @Rohit, for your information, DownloadText calls DownloadToStream internally anyway. So, the initial problem you were seeing probably was something else.

    @Will, a missing container or blob should actually result in 404, not 403.

    Thursday, February 27, 2014 5:52 PM