Examples of Using REST Interface with the SQL Data Services

[This document supports a preliminary release of a software product that may be changed substantially prior to final commercial release. This document is provided for informational purposes only.]

SOAP and REST interfaces may be used when developing applications using the Microsoft® SQL Data Services (SDS). These topics provide examples that use the REST interface.

Creating an Authority Using REST

Creating a Container Using REST

Deleting a Container Using REST

Creating an Entity Using REST

Updating an Entity Using REST

Deleting an Entity Using REST

If using Visual Studio to test the C# samples in these topics, the steps to create a working sample are:

  1. Create a Visual Studio console application.
  2. Enter the code that is provided in the specific topic. You will need to update the code as follows:
    • Provide your credentials (user name and password).
    • In some samples, you may need to update the code and provide appropriate container/entity ids for the objects that you are dealing with. For example, if you are updating an entity, you will need to provide an identifier for the entity that you want to update and the identifier for the container in which the entity resides.

Useful Queries

You may find the following queries useful in locating your authority, containers, and entities. In all the following examples, data.database.windows.net refers to the service, and v1 refers to the service version.

Cc512403.note(en-us,SQL.100).gif
NOTE: SQL Data Services support content type, application/x-ssds+xml, for the non-blob entities. When executing queries in the browser, the browser needs to be aware of this content type. For more information see, Guidelines and Limitations for related content type guidelines. Alternatively, if you install SDS SDK, the installation will update registry accordingly. For more information, see SQL Data Services (SDS) SDK (Beta).

Understanding URI Space

When writing these samples, you will deal with various URIs that are classified as authority, container, and entity URIs.

  • An authority URI is used to retrieve information about a particular authority instance. The authority URI is also used to query the containers.

    https://<authority-id>.data.database.windows.net/v1/
    
  • A container URI is used to retrieve information about a particular container instance. It is also used to query the entities.

    https://<authority-id>.data.database.windows.net/v1/<container-id>
    
  • An entity URI can be used to retrieve a particular entity.

    https://<authority-id>.data.database.windows.net/v1/<container-id>/<entity-id>
    

These URIs set the scope for the query that optionally follows.

Locating Containers

To locate all containers in an authority, enter the authority URI followed by an empty query.

https://<authority-id>.data.database.windows.net/v1/?q=''

To find a specific container, you write a container URI.

https://<authority-id>.data.database.windows.net/v1/<container-id>

Locating Entities

To find all the entities in a specific container, enter the container URI, followed by an empty query.

https://<authority-id>.data.database.windows.net/v1/<container-id>?q=''

To find a set of entities in a container, enter the container URI, followed by a query for the entity.

https://<authority-id>.data.database.windows.net/v1/<container-id>?q='from e in entities where e.Kind=="MyKind" select e' 

See Also

Concepts

Examples of Using SOAP and REST Interfaces with the SQL Data Services
SDS Data Model Overview (Authorities, Containers, Entities and Flexible Entities)