The Create User Setting operation creates a user setting with the user setting object provided in the body of the post, for the user ID specified in the URI.
Request
The Create User Setting request may be specified
as follows. Replace <user -id>
with your
resource provider ID
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 | |
---|---|
<SettingBatch xmlns:i="http://www.w3.org/2001/XMLSchema-instance" xmlns="http://schemas.datacontract.org/2004/07/Microsoft.WindowsAzure.Management.Setting.Client.DataContracts"> <Method>InsertOrUpdate</Method> <SettingCollection> <Setting> <ExpirationInDays i:nil="true" /> <Name>Some Setting Name</Name> <Path>Some path</Path> <Value>ABC</Value> </Setting> </SettingCollection> <SettingStoreId> <Id>user@contoso.com</Id> <Store>Some store</Store> <Type>User</Type> </SettingStoreId> </SettingBatch> |
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
Copy Code | |
---|---|
<SettingCollection xmlns:i="http://www.w3.org/2001/XMLSchema-instance" xmlns="http://schemas.datacontract.org/2004/07/Microsoft.WindowsAzure.Management.Setting.Client.DataContracts"> <Setting> <ExpirationInDays i:nil="true" /> <Name>Some Setting Name</Name> <Path>Some Path</Path> <Value>ABC</Value> </Setting> </SettingCollection> |
Example
Create a user setting.
Copy Code | |
---|---|
public void CreateUserSetting(string adminServiceEndpoint) { HttpClient httpClient = new HttpClient(); httpClient.DefaultRequestHeaders.Authorization = new AuthenticationHeaderValue("BASIC", Convert.ToBase64String(UnicodeEncoding.Unicode.GetBytes("AdminPortal:" + password))))); string subscriptionEndpoint = adminServiceEndpoint + "settings/"; var settingStoreId = new SettingStoreId("Global", "User", "test@test.com"); var setting = new Setting() { Path = "some path", Name = "setting name", Value = "your value" }; var settingCollection = new SettingCollection {setting}; var batch = new SettingBatch(settingStoreId, settingCollection, SettingMethods.InsertOrUpdate); Console.WriteLine(httpClient.PostAsXmlAsync<SettingBatch>(subscriptionEndpoint, batch).Result.EnsureSuccessStatusCode() + "Successfully created User Setting"); } |