The Create User operation creates a user with the user object provided in the body of the post.
Request
The Create User request may be specified as follows.
Method | Request URI | HTTP Version |
---|---|---|
POST |
|
HTTP/1.1 |
URI Parameters
None.
Request Headers
The following table describes request headers.
Request Header | Description |
---|---|
Content-Type |
Required. Set this header to application/xml; charset=utf-8. |
Authorization |
Required. Specifies the credentials for this request. The value of this header must be set Negotiate <token>. |
Request Body
The format for the request body is as follows:
Copy Code | |
---|---|
<User xmlns:i="http://www.w3.org/2001/XMLSchema-instance" xmlns="http://schemas.microsoft.com/windowsazure"> <Name>test1@test.com</Name> <Email>test1@test.com</Email> <State>Active</State> </User> |
Important |
---|
The order of the elements in the request body is significant. If an element is required, it must appear in the XML in the order shown above. |
The following table describes the key elements of the request body:
Element Name |
Description |
Name |
A name for the user |
|
The email address of the user |
State |
Whether the user is Active |
Response
The response includes an HTTP status code, a set of response headers, and a response body.
Status Code
The status code is embedded in the response for this operation; if successful, it will be status code 201 (CREATED.)
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 |
---|---|
None |
None |
Response Body
None
Example
Create a user.
Copy Code | |
---|---|
public void CreateUser(string adminServiceEndpoint) { HttpClient httpClient = new HttpClient(); httpClient.DefaultRequestHeaders.Authorization = new AuthenticationHeaderValue("BASIC", Convert.ToBase64String(UnicodeEncoding.Unicode.GetBytes("AdminPortal:" + password))))); string subscriptionEndpoint = adminServiceEndpoint + "users/"; var userInfo = new User() { Name = "user@contoso.com", Email = "user@contoso.com", State = UserState.Active, }; httpClient.PostAsXmlAsync<User>(subscriptionEndpoint, userInfo).Result.EnsureSuccessStatusCode(); } |