An HTTP header that’s mandatory for this request is not specified: One Cause for Azure Error Message

I recently posted sample code that shows copying a file up to Azure Blob Storage in One Page Of Code. In repurposing the code that deals with Azure Queues, I encountered a perplexing error message in using the Azure CloudQueue class from the SDK. I was able to figure it out, and the actual solution may actually be less interesting than how the solution was discovered, so here it is…

The story of “an HTTP header that’s mandatory for this request is not specified”

First of all, my call to get a queue reference had completed without incident:

queue = queueStorage.GetQueueReference(“myqueue”);

Next I executed this line of seemingly innocuous code:

queue.CreateIfNotExist();

An Exception was raised – a “Microsoft.WindowsAzure.StorageClient.StorageClientException” to be exact – with the following message:

Exception Message: “An HTTP header that’s mandatory for this request is not specified” 

“An HTTP header that’s mandatory for this request is not specified.”

"An HTTP header that's mandatory for this request is not specified."

That didn’t help, so I then checked the Inner Exception:

Inner Exception Message: “The remote server returned an error: (400) Bad Request.”

"The remote server returned an error: (400) Bad Request."

That didn’t help either. So I fired up Fiddler and looked at the http Request and Response (Raw views shown here):

Screen shot mentioning “Server: Windows-Azure-Blob/1.0 Microsoft-HTTPAPI/2.0” and “<HeaderName>x-ms-blob-type</HeaderName>”

If you look carefully in the Response, you will see there are two references to Blobs:

Circled “Server: Windows-Azure-Blob/1.0 Microsoft-HTTPAPI/2.0” and “<HeaderName>x-ms-blob-type</HeaderName>”

Blobs? Yes, blobs.

Blobs… That was my problem. This was supposed to be code to create a queue. A quick check back to my code immediately revealed a cut and paste error on my part. Two actually, as I tried this both against Development Storage and against live Cloud Storage with the same error.

This was the problem – the culpret – the issue – the bug:

    var clientStorageAccount = CloudStorageAccount.DevelopmentStorageAccount;
    CloudQueueClient queueStorage = new CloudQueueClient(clientStorageAccount.BlobEndpoint.AbsoluteUri,clientStorageAccount.Credentials);

As was this:

    CloudQueueClient queueStorage = new CloudQueueClient(String.Format(“http://{0}.blob.core.windows.net”, accountName), creds);

Replacing “Blob” with “Queue” did the trick for both snippets.

Pay the Fiddler

The error message was tricky, requiring that I fire up Fiddler to see the error of my ways. So..  Be careful out there when you Cut & Paste. Or don’t hack at 9:30 in the night. Or check out a Fiddler http trace, which may have additional information. Or all three..

Checking the Fiddler trace is really the interesting lesson from this post. If you are perplexed over some error condition, look at the raw http traffic for additional details – there may be a new clue in there.

Did This Post Help You?

Please leave me a comment if this blog post helped you or if you encountered the same exact error.

3 thoughts on “An HTTP header that’s mandatory for this request is not specified: One Cause for Azure Error Message

  1. 2012canadagoosejakkersale.blogspot.com

    Had it not been for the alarm clock she wouldn’t have been late.The figure seems all Right.So far£¬So good.I doubted whether the story is true.His father runs a restaurant.The meeting was scheduled for two hours£¬ but it is now over yetThe meeting was scheduled for two hours£¬ but it is now over yetHe broke his words once again.Time is up.Once you begin£¬you must continue.

    Reply
  2. gorillamask

    Vielleicht findet er noch heim in das Waldhaus
    mir die am Traumtag erhaltene Nachricht,
    dass die Klinik, in deren Hoersaal ich als Gast meine Vorlesungen abhalte, demnaechst anderswohin verlegt
    werden solle. Para ahli merekomendasikan kompromi:
    mengajukan permohonan kartu kredit satu atau dua selama tahun kuliah Anda,
    tapi menghindari godaan untuk menyebar uang. ffentlichkeit, die in der Therapie bedarf, ist die
    Hilfe, aber nicht wei.

    Reply

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s