Note
Access to this page requires authorization. You can try signing in or changing directories.
Access to this page requires authorization. You can try changing directories.
Update using the HTTP POST operation.
Code Examples
Request
| Method | Request URI | HTTP Version |
|---|---|---|
POST |
HTTPS://<HOST>:<PORT>/00000000-0000-0000-0000-000000000000/Credentials |
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/Credentials 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
<?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.Credential" scheme="https://schemas.microsoft.com/ado/2007/08/dataservices/scheme" />
<id />
<title />
<updated>2014-04-16T17:20:47Z</updated>
<author>
<name />
</author>
<content type="application/xml">
<m:properties>
<d:CreationTime m:type="Edm.DateTime">0001-01-01T00:00:00</d:CreationTime>
<d:CredentialID m:type="Edm.Guid">00000000-0000-0000-0000-000000000000</d:CredentialID>
<d:Description>Test Credential Description</d:Description>
<d:LastModifiedTime m:type="Edm.DateTime">0001-01-01T00:00:00</d:LastModifiedTime>
<d:Name>Test Credential Name</d:Name>
<d:RawValue>test</d:RawValue>
<d:TenantID m:type="Edm.Guid">00000000-0000-0000-0000-000000000000</d:TenantID>
<d:UserName>TESTUSER</d:UserName>
<d:Value m:null="true" />
</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
<?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/Credentials(guid'22dd5566-b37a-42d4-a913-3ee859255062')</id>
<category term="Orchestrator.ResourceModel.Credential" scheme="https://schemas.microsoft.com/ado/2007/08/dataservices/scheme" />
<link rel="edit" title="Credential" href="Credentials(guid'22dd5566-b37a-42d4-a913-3ee859255062')" />
<title />
<updated>2014-04-16T17:20:48Z</updated>
<author>
<name />
</author>
<content type="application/xml">
<m:properties>
<d:CredentialID m:type="Edm.Guid">22dd5566-b37a-42d4-a913-3ee859255062</d:CredentialID>
<d:TenantID m:type="Edm.Guid">00000000-0000-0000-0000-000000000000</d:TenantID>
<d:Name>Test Credential Name</d:Name>
<d:UserName>TESTUSER</d:UserName>
<d:RawValue m:null="true" />
<d:Value>AKmi+x15G2r5ZglUDuGeeg==</d:Value>
<d:Description>Test Credential Description</d:Description>
<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 Credential.
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 credential instance.
var testCredential = new Credential();
// Populate various properties with values.
testCredential.Name = "Test Credential Name";
testCredential.UserName = "TESTUSER";
testCredential.RawValue = "test";
testCredential.Description = "Test Credential Description";
// Add the new credential instance to the Variables collection.
// Note: This action is queued up until the SaveChanges action is called.
SMAService.AddToCredentials(testCredential);
// Save all pending actions (client -> server communication initiated).
SMAService.SaveChanges();
}
catch (Exception ex)
{
throw new ApplicationException("An error occurred during execution.", ex.InnerException);
}
}
}
}