Create (POST) Variables
Update using the HTTP POST operation.
Code Examples
Request
Method | Request URI | HTTP Version |
---|---|---|
POST |
HTTPS://<HOST>:<PORT>/00000000-0000-0000-0000-000000000000/Variables |
HTTP/1.1 |
Request URI Parameters
The POST operation has no parameters.
Request URI Example
Example URI |
---|
POST https://sma-server:9090/00000000-0000-0000-0000-000000000000/Variables HTTP/1.1 |
Request Headers
For more information about the common request headers used by this operation, see Standard Service Management Automation POST/GET/PUT/DELETE Headers.
Request Body
The POST request body.
<?xml version="1.0" encoding="utf-8"?><entry xmlns="http://www.w3.org/2005/Atom" xmlns:d="https://schemas.microsoft.com/ado/2007/08/dataservices" xmlns:m="https://schemas.microsoft.com/ado/2007/08/dataservices/metadata">
<category term="Orchestrator.ResourceModel.Variable" scheme="https://schemas.microsoft.com/ado/2007/08/dataservices/scheme" />
<id />
<title />
<updated>2014-04-01T14:45:58Z</updated>
<author>
<name />
</author>
<content type="application/xml">
<m:properties>
<d:CreationTime m:type="Edm.DateTime">0001-01-01T00:00:00</d:CreationTime>
<d:Description>Test Variable Description</d:Description>
<d:IsEncrypted m:type="Edm.Boolean">false</d:IsEncrypted>
<d:LastModifiedTime m:type="Edm.DateTime">0001-01-01T00:00:00</d:LastModifiedTime>
<d:Name>Test Variable Name</d:Name>
<d:TenantID m:type="Edm.Guid">00000000-0000-0000-0000-000000000000</d:TenantID>
<d:Value>Test Variable Value</d:Value>
<d:VariableID m:type="Edm.Guid">00000000-0000-0000-0000-000000000000</d:VariableID>
</m:properties>
</content>
</entry>
Response
Response Codes
Response Code | Description |
---|---|
HTTP/1.1 201 Created |
Request fulfilled. |
Response Headers
For more information about the common response headers used by this operation, see Standard Service Management Automation POST/GET/PUT/DELETE Headers.
Response Body
The POST response body.
<?xml version="1.0" encoding="utf-8"?><entry xml:base="https://sma-server:9090/00000000-0000-0000-0000-000000000000/" xmlns="http://www.w3.org/2005/Atom" xmlns:d="https://schemas.microsoft.com/ado/2007/08/dataservices" xmlns:m="https://schemas.microsoft.com/ado/2007/08/dataservices/metadata">
<id>https://sma-server:9090/00000000-0000-0000-0000-000000000000/Variables(guid'159fb0d4-8c32-4388-8944-a7ac07678d18')</id>
<category term="Orchestrator.ResourceModel.Variable" scheme="https://schemas.microsoft.com/ado/2007/08/dataservices/scheme" />
<link rel="edit" title="Variable" href="Variables(guid'159fb0d4-8c32-4388-8944-a7ac07678d18')" />
<title />
<updated>2014-04-01T14:46:02Z</updated>
<author>
<name />
</author>
<content type="application/xml">
<m:properties>
<d:VariableID m:type="Edm.Guid">159fb0d4-8c32-4388-8944-a7ac07678d18</d:VariableID>
<d:TenantID m:type="Edm.Guid">00000000-0000-0000-0000-000000000000</d:TenantID>
<d:Name>Test Variable Name</d:Name>
<d:Value>Test Variable Value</d:Value>
<d:Description>Test Variable Description</d:Description>
<d:IsEncrypted m:type="Edm.Boolean">false</d:IsEncrypted>
<d:CreationTime m:type="Edm.DateTime">0001-01-01T00:00:00</d:CreationTime>
<d:LastModifiedTime m:type="Edm.DateTime">0001-01-01T00:00:00</d:LastModifiedTime>
</m:properties>
</content>
</entry>
Code Examples
The following example creates a new Variable.
namespace CodeSample.Microsoft.SystemCenter.SMA
{
public class SMASamples
{
public static void Main()
{
// Replace this with the name of your SMA web service endpoint.
string serviceEndPoint = "https://sma-server:9090/00000000-0000-0000-0000-000000000000";
// Setup the connection to SMA
OrchestratorApi SMAService = new OrchestratorApi(new Uri(serviceEndPoint));
// Set credentials to the default or to a specific user.
((DataServiceContext)SMAService).Credentials = CredentialCache.DefaultCredentials;
//((DataServiceContext)SMAService).Credentials = new NetworkCredential("user", "pwd", "domain");
try
{
// Create a new variable instance.
var testVariable = new Variable();
// Populate various properties with values.
testVariable.Name = "Test Variable Name";
testVariable.Value = "Test Variable Value";
testVariable.Description = "Test Variable Description";
// Add the new variable instance to the Variables collection.
// Note: This action is queued up until the SaveChanges action is called.
SMAService.AddToVariables(testVariable);
// Save all pending actions (client -> server communication initiated).
SMAService.SaveChanges();
}
catch (Exception ex)
{
throw new ApplicationException("An error occurred during execution.", ex.InnerException);
}
}
}
}