XmlException: Root element is missing while performing PUT operation
Published Jul 26 2019 02:53 AM 4,530 Views


While invoking a REST API to perform PUT message to add a message to the Azure Queue storage, I was getting the below exception:



Microsoft.WindowsAzure.Storage.StorageException occurred


Message=Root element is missing.

Source=<Cannot evaluate the exception source>


   at Microsoft.WindowsAzure.Storage.Core.Executor.Executor.ExecuteSync[T](RESTCommand`1 cmd,

     IRetryPolicy policy, OperationContext operationContext)

   at Microsoft.WindowsAzure.Storage.Queue.CloudQueue.AddMessage(CloudQueueMessage message, Nullable`1

     timeToLive, Nullable`1 initialVisibilityDelay, QueueRequestOptions options, OperationContext


   at QueueSASSender.Program.Main(String[] args) in E:\Cxfiles\117092716404612\2017-11-

     03\QueueSASSender\QueueSASSender\Program.cs:line 41


Inner Exception 1:

XmlException: Root element is missing.



My sample code was as shown below:



var queueClient =   new CloudQueueClient(new Uri("https://*****.queue.core.windows.net:443/"),

                   new StorageCredentials("?st=2018-11-27T23%3A22%3A00Z&se=2020-12-




var queue = queueClient.GetQueueReference("myqueue");

queue.AddMessage(new CloudQueueMessage("my message"));




I started my investigation with the SAS Token which was in the below format:



The one that grabbed my attention was ‘sv’ (Service Version). I could see that I was using an older version to formulate the token (sv=2012-02-12).


I tried to compose the request again and confirmed if that was indeed the cause of this issue. I created a new SAS token using a different version of the sv (Service Version), though not the most recent one.


Below is my new SAS token:




I have referred to the document which says the new SDK is expecting the Put Message API call to return a valid XML response. Since the SAS signature had an older version no response was returned from the Azure Queue Storage.




Also note that the message was getting added in the queue though we got the exception in the response. A workaround may be to simply ignore the storage exception generated by this API, but this carries risk as you may be ignoring genuine exceptions too.


We strongly recommend that you regenerate the SAS signature to allow you to take advantage of all the features that have been added over the years to the Azure Storage SDK.


Hope this helps.



Version history
Last update:
‎Jul 30 2019 10:19 PM
Updated by: