Eksporter (0) Skriv ut
Vis alt
EN
Dette innholdet er ikke tilgjengelig på ditt språk, men her er den engelske versjonen.

Insert record operation

Updated: June 25, 2013

Inserts a new item into a table.

The request may be specified as follows. Replace <service_name> with your mobile service name and <table_name> with the name of the table to access.

 

HTTP Verb Request URI HTTP Version

POST

https://<service_name>.azure-mobile.net/tables/<table_name>

HTTP/1.1

 

URI Parameter Required Description

noscript

No

When a value of true is supplied, the execution of registered scripts is suppressed. To suppress script execution, you must also supply the service master key in the X-ZUMO-MASTER header.

The following table describes the request headers.

 

Request Header Required  

Accept

No

Set this header to application/json.

Content-Length

Yes

The length of the request body.

Content-Type

No

Set this header to application/json.

X-ZUMO-APPLICATION

Conditional

The application key of the mobile service. You must specify a valid application key when required to access the table operation. This is the default table operation access permission.

X-ZUMO-AUTH

Conditional

The service-generated authentication token for an authenticated user. You must specify a token for an authenticated user when required to access the table operation.

X-ZUMO-MASTER

Conditional

The service master key. You should only include this key when administrator access is required to access the table operation.

securitySecurity Note
The service master key is a critical security credential that provides administrator access to your data service. Do not share this secret with anyone or distribute it with your app. This key must always be securely distributed over an encrypted channel.

The inserted item must be an object encoded in JavaScript Object Notation (JSON) format.

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

A successfully operation returns status code 201 (Created).

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

Content-Length

The length of the response body.

Content-Type

Header set to application/json.

Location

URI that represents the inserted object. This URI is used in a GET request to return the inserted data row.

x-zumo-version

Indicates which version of the runtime executed the request.

The JSON representation of the inserted item, which includes the ID for the item generated by the mobile service.

Authorization depends on the access permission requirements for the table operation, which are summarized as follows:

 

Table operation access permission Required authorization header

Everyone

None

Anybody with the application key

X-ZUMO-APPLICATION

Only Authenticated Users

X-ZUMO-AUTH

Only Scripts and Admins

X-ZUMO-MASTER

Access permissions for individual table operations are set in the Windows Azure Management Portal. For more information, see Permissions.

The following example URI inserts a new item in the TodoItem table.

POST https://todolist.azure-mobile.net/tables/TodoItem

The request is sent with the following headers.

Accept: application/json
X-ZUMO-APPLICATION: UzMAOXRlJdZyqibeUqCMoZZMrUXIRs92
Content-Type: application/json
Host: todolist.azure-mobile.net
Content-Length: 49

The request is sent with the following JSON object in the body.

{"text":"Complete the tutorial","complete":false}

After the request has been sent, the following response is returned.

HTTP/1.1 201 Created
Content-Type: application/json
x-zumo-version: Zumo.Main.0.1.6.527.Runtime
Date: Thu, 20 Sep 2012 05:59:27 GMT
Content-Length: 57

{"text":"Complete the tutorial","complete":false,"id":18}

Vis:
© 2014 Microsoft