Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 7128635
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 28, 20262026-05-28T11:09:32+00:00 2026-05-28T11:09:32+00:00

I am attempting to write to Azure Table Storage without using the TableContext and

  • 0

I am attempting to write to Azure Table Storage without using the TableContext and Table ServiceEntity classes, I just want to send raw XML (I want the flexibility of defining the schema on the fly).

When I do this (and sign the request using the method in the SDK) I get a 404. No idea why.

The table exists. I have omitted my credentials, but they are correct in my original code.

The code snippet below illustrates the problem.

Any suggestions are very welcome!

using System.IO;
using System.Net;
using System.Text;
using Microsoft.WindowsAzure.StorageClient.Protocol;

public static class Program
{
    public static void Main()
    {
        Credentials credentials = new Credentials("xxx", @"yyy");
        var uri = string.Format(@"http://{0}.table.core.windows.net/{1}(PartitionKey='{2}',RowKey='{3}')", credentials.AccountName, "TableName", "1", "1");
        var webRequest = (HttpWebRequest)WebRequest.Create(uri);
        webRequest.Method = "POST";
        webRequest.Headers.Add("DataServiceVersion", "2.0;NetFx");
        webRequest.Headers.Add("MaxDataServiceVersion", "2.0;NetFx");
        webRequest.ContentType = @"application/atom+xml";
        WriteToRequestStream(uri, webRequest);
        TableRequest.SignRequestForSharedKeyLite(webRequest, credentials);
        var response = webRequest.GetResponse(); // 404 thrown here
    }

    private static void WriteToRequestStream(string uri, HttpWebRequest webRequest)
    {
        var sb = new StringBuilder();
        sb.Append(@"<?xml version='1.0' encoding='utf-8' standalone='yes'?><entry xmlns:d='http://schemas.microsoft.com/ado/2007/08/dataservices' xmlns:m='http://schemas.microsoft.com/ado/2007/08/dataservices/metadata' xmlns='http://www.w3.org/2005/Atom'><title /><updated>2009-03-18T11:48:34.9840639-07:00</updated><author><name /></author><id>");
        sb.Append(uri);
        sb.Append(@"</id><content type='application/xml'><m:properties></m:properties></content></entry>");
        string body = sb.ToString();
        webRequest.ContentLength = body.Length;
        UTF8Encoding encoding = new UTF8Encoding();
        byte[] bytes = encoding.GetBytes(body);
        using (Stream requestStream = webRequest.GetRequestStream())
        {
            requestStream.Write(bytes, 0, bytes.Length);
        }
    }
}
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-28T11:09:33+00:00Added an answer on May 28, 2026 at 11:09 am

    When creating an entity, you have three choices:

    1. Insert in which you POST to http://myaccount.table.core.windows.net/mytable
    2. Insert or Merge in which you MERGE to http://myaccount.table.core.windows.net/mytable(PartitionKey="myPartitionKey", RowKey="myRowKey1")
    3. Insert or Replace in which you PUT to http://myaccount.table.core.windows.net/mytable(PartitionKey="myPartitionKey", RowKey="myRowKey1")

    The latter two, however, are not supported by the local emulator.

    Additionally, I took a look at the request your code is making using Fiddler, and it’s missing the following headers:

    • Authorization
    • Date or x-ms-date
    • x-ms-version

    To include the headers correctly, try this code:

    var webRequest = (HttpWebRequest)WebRequest.Create(uri);
    webRequest.Method = "PUT";
    webRequest.Headers.Add("DataServiceVersion", "2.0;NetFx");
    webRequest.Headers.Add("MaxDataServiceVersion", "2.0;NetFx");
    webRequest.Headers.Add("x-ms-version", "2011-08-18");
    webRequest.ContentType = @"application/atom+xml";
    TableRequest.SignRequestForSharedKeyLite(webRequest, credentials);
    WriteToRequestStream(uri, webRequest);
    var response = webRequest.GetResponse();
    

    Notice how I changed the method to do an Insert or Replace. I also inverted the call to SignRequestForSharedKeyLite and added a x-ms-version header with version 2011-08-18 otherwise Insert or Replace is not supported.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I am attempting to write a file to external storage in android. I keep
I am attempting to write a .htaccess file to direct to and send index
I'm attempting to write a custom widget and I want to use existing UI
I'm presently attempting to write a few classes to aid me in writing various
I am attempting to write a simple game server for an Android game using
I'm attempting to write a simple buffer overflow using C on Mac OS X
I am attempting to write a XML parser in VB6. The standards that the
I am attempting to write a two-pass algorithm incorporating some legacy code. I want
I've been attempting to write an XML parser to read through a Wikipedia XML
I'm attempting to write a program in Linux using C++ that counts the number

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.