SALES: 1-800-867-1380
0 out of 4 rated this helpful - Rate this topic

Create Table (REST API)

Updated: November 26, 2013

The Create Table operation creates a new table in the storage account.

The Create Table request may be constructed as follows. HTTPS is recommended. Replace myaccount with the name of your storage account:

 

Method Request URI HTTP Version

POST

https://myaccount.table.core.windows.net/Tables

HTTP/1.1

Emulated Storage Service URI

When making a request against the emulated storage service, specify the emulator hostname and Table service port as 127.0.0.1:10002, followed by the emulated storage account name:

 

Method Request URI HTTP Version

POST

http://127.0.0.1:10002/devstoreaccount1/Tables

HTTP/1.1

The Table service in the storage emulator differs from the Windows® Azure™ Table service in several ways. For more information, see About Development Storage and Differences Between the Storage Emulator and Windows Azure Storage Services.

URI Parameters

None.

Request Headers

The following table describes required and optional request headers.

 

Request header Description

Authorization

Required. Specifies the authentication scheme, account name, and signature. For more information, see Authentication for the Windows Azure Storage Services.

Date or x-ms-date

Required. Specifies the Coordinated Universal Time (UTC) for the request. For more information, see Authentication for the Windows Azure Storage Services.

x-ms-version

Optional. Specifies the version of the operation to use for this request. For more information, see Versioning for the Blob, Queue, and Table Services in Windows Azure.

Content-Type

Required. Specifies the content type of the payload. Possible values are:

  • application/atom+xml

  • application/json

For more information, see Payload Format for Table Service Operations.

Accept

Optional. Specifies the accepted content-type of the response payload. Possible values are:

  • application/atom+xml

  • application/json;odata=nometadata

  • application/json;odata=minimalmetadata

  • application/json;odata=fullmetadata

For more information, see Payload Format for Table Service Operations.

Prefer

Optional. Specifies whether the response should include the inserted entity in the payload. Possible values are return-no-content and return-content.

For more information about this header, see Setting the Prefer Header to Manage Response Echo on Insert Operations.

Content-Length

Required. The length of the request body.

x-ms-client-request-id

Optional. Provides a client-generated, opaque value with a 1 KB character limit that is recorded in the analytics logs when storage analytics logging is enabled. Using this header is highly recommended for correlating client-side activities with requests received by the server. For more information, see About Storage Analytics Logging and Windows Azure Logging: Using Logs to Track Storage Requests.

Request Body

The request body specifies the name of the table to be created. Note that table names must conform to the naming restrictions described in Understanding the Table Service Data Model.

The request body is an OData entity set, which can be expressed as an Atom feed or as JSON.

Atom

The request body as an Atom feed has the following general format.

<?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/> 
      <content type="application/xml">
        <m:properties>
          <d:TableName>mytable</d:TableName>
        </m:properties>
      </content> 
    </entry>

JSON

The request body as a JSON feed has the following general format.

{ 
    "TableName":"mytable"
}

For guidance about valid table names, see the Table Names section in Understanding the Table Service Data Model.

The response includes an HTTP status code, a set of response headers, and a response body.

Status Code

The status code depends on the value of the Prefer header. If the Prefer header is set to return-no-content, then a successful operation returns status code 204 (No Content). If the Prefer header is not specified or if it is set to return-content, then a successful operation returns status code 201 (Created). For more information, see Setting the Prefer Header to Manage Response Echo on Insert Operations.

For information about status codes, see Status and Error Codes and Table Service Error Codes.

Response Headers

The response for this operation includes the following headers. The response may also include additional standard HTTP headers. All standard headers conform to the HTTP/1.1 protocol specification.

 

Response header Description

x-ms-request-id

This header uniquely identifies the request that was made and can be used for troubleshooting the request. For more information, see Troubleshooting API Operations.

x-ms-version

Indicates the version of the Table service used to execute the request. This header is returned for requests made against version 2009-09-19 and later.

Date

A UTC date/time value generated by the service that indicates the time at which the response was initiated.

Preference-Applied

Indicates whether the Prefer request header was honored. If the response does not include this header, then the Prefer header was not honored. If this header is returned, its value will either be return-content or return-no-content.

For more information, see Setting the Prefer Header to Manage Response Echo on Insert Operations.

Content-Type

Indicates the content type of the payload. The value depends on the value specified for the Accept request header. Possible values are:

  • application/atom+xml

  • application/json;odata=nometadata

  • application/json;odata=minimalmetadata

  • application/json;odata=fullmetadata

For more information about content types, see Payload Format for Table Service Operations.

Response Body

If the request includes the Prefer header with the value return-no-content, no response body is returned. Otherwise, the response body is an OData entity set.

Atom

Here is a sample Atom response for the Create Table operation.

<?xml version="1.0" encoding="utf-8" standalone="yes"?>
<entry xml:base="https://myaccount.table.core.windows.net/" 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"> <id>https://myaccount.table.core.windows.net/Tables('mytable')</id>
  <title type="text"></title>
  <updated>2013-10-24T17:18:54.7062347Z</updated>
  <author>
    <name />
  </author>
  <link rel="edit" title="Tables" href="Tables('mytable')" />
  <category term="myaccount.Tables" scheme="http://schemas.microsoft.com/ado/2007/08/dataservices/scheme" />
  <content type="application/xml">
    <m:properties>
      <d:TableName>mytable</d:TableName>
    </m:properties>
  </content>
</entry>

JSON

Here are the response payloads in JSON for different Control Levels.

Full Metadata

{

    "odata.metadata":"https://myaccount.table.core.windows.net/$metadata#Tables/@Element",

    "odata.type":" myaccount.Tables",

    "odata.id":"https://myaccount.table.core.windows.net/Tables('mytable')",

    "odata.editLink":"Tables('mytable')",

    "TableName":"mytable"

}

Minimal Metadata

{

    "odata.metadata":"https://myaccount.table.core.windows.net/$metadata#Tables/@Element",

    "TableName":"mytable"

}

No Metadata

{

    "TableName":"mytable"

}

Only the account owner may call this operation.

None.

Did you find this helpful?
(1500 characters remaining)
Thank you for your feedback
Show:
© 2014 Microsoft. All rights reserved.