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/Certificates |
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/Certificates 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.Certificate" scheme="https://schemas.microsoft.com/ado/2007/08/dataservices/scheme" />
<id />
<title />
<updated>2014-04-15T20:04:13Z</updated>
<author>
<name />
</author>
<content type="application/xml">
<m:properties>
<d:CertificateID m:type="Edm.Guid">00000000-0000-0000-0000-000000000000</d:CertificateID>
<d:CreationTime m:type="Edm.DateTime">0001-01-01T00:00:00</d:CreationTime>
<d:Description>Certificate description</d:Description>
<d:ExpiryTime m:type="Edm.DateTime">2039-12-31T15:59:59</d:ExpiryTime>
<d:LastModifiedTime m:type="Edm.DateTime">0001-01-01T00:00:00</d:LastModifiedTime>
<d:Name>Test Certificate</d:Name>
<d:RawValue>IAAAAAEAAADLAQAAMIIBxzCCAXGgAwIBAgIQ6HiYt4ogwYtOIAaaaYqd1jANBgkqhkiG9w0BAQQFADAWMRQwEgYDVQQDEwtSb290IEFnZW5jeTAeFw0wMzA0MDUxOTUwMTlaFw0zOTEyMzEyMzU5NTlaMCIxIDAeBgNVBAMTF0pvZSdzLVNvZnR3YXJlLUVtcG9yaXVtMIGfMA0GCSqGSIb3DQEBAQUAA4GNADCBiQKBgQCkwfHx50UjZSiTTozk0zzYXcrrbj7qlO/hXX8UGbbllfDB5+noDrSTl2Mdtrwwf80Oy6VbaDnPz3iNUG+VDM4tcVrLbHNMjSrk5Ndg8rK6EeWVHuYE7PUlgLTPU/2W4idPIFvUUv5IOa8q6SxD5Twt+xbsGz4afanH18J95xwVHQIDAQABo0swSTBHBgNVHQEEQDA+gBAS5AktBh0dTwCNYSHcFmRjoRgwFjEUMBIGA1UEAxMLUm9vdCBBZ2VuY3mCEAY3bACqAGSKEc+41KpcNfQwDQYJKoZIhvcNAQEEBQADQQBqbAerWZcQboC8qxwAPVoJz3Raee8hiyt4eQYETACAMDn5Io6u6nUpvzd6CFSKcFZ9pWjTdBlzm8Lm/qHDmQ3u</d:RawValue>
<d:TenantID m:type="Edm.Guid">00000000-0000-0000-0000-000000000000</d:TenantID>
<d:Thumbprint>8044E2A478067D4F8867BB57A11006C1799A611D</d:Thumbprint>
<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
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/Certificates(guid'd5db8755-c6d8-43c1-bdff-df0cc632b1df')</id>
<category term="Orchestrator.ResourceModel.Certificate" scheme="https://schemas.microsoft.com/ado/2007/08/dataservices/scheme" />
<link rel="edit" title="Certificate" href="Certificates(guid'd5db8755-c6d8-43c1-bdff-df0cc632b1df')" />
<title />
<updated>2014-04-15T20:04:14Z</updated>
<author>
<name />
</author>
<content type="application/xml">
<m:properties>
<d:CertificateID m:type="Edm.Guid">d5db8755-c6d8-43c1-bdff-df0cc632b1df</d:CertificateID>
<d:TenantID m:type="Edm.Guid">00000000-0000-0000-0000-000000000000</d:TenantID>
<d:Name>Test Certificate</d:Name>
<d:RawValue m:null="true" />
<d:Value>MsaVHj0uWRV6bLGpBl8lraF5JzTzSalI9F0rAwIJqt/6yNgRZ2cciHxlkA0aGC0+V3fiXu+no/Ts5DJnxjAY6SWaivjXmqViSc8I/BYNwi3l5qjeEp0F7izsNfDj4okr+r2Yp3joOltW78Zpz9z3FYr5DFSLe03keeOy0CeyP2rAJx/Cj6R+opiyGOVjfYmm3BdkXDWlAeS0SeKCdSPKPm3ssXu88Td3VJIGA5ROqQ5/whLfwpvv2kiQiyV4Dz91Hv2tErMO0TQZDnGIpRKojR0PjMl/Q7J1I43CcSQfACu5NNRiBrWQiIxV5BA9RIWlTa26Ykrt5NinsOhuy80GRATR3pdBYGNTkMEyflnHzAB8BhMA1s3puqPjAViIhghMUwQhi5TVTa03F54WBfNeyqWM4jTJOaf+Ji7PI9HfI25mgyiVSXTgbcovs6SjuLg9R8+/ROTLzodWGqT4VTCWnJ2JJ/W0FzMelayDYtIgMBxVwpwPzkJRMYpq0EYE+MlJa8bQncgFeLbCgr2PWx5IQOr0jQTWTNPpTj1x7jFu3I44tjdxjgFH6TlZtakw1HbZK3AbUrvhm+y+KIDyoXGXWhB3S7SX02MTmqzGwXEKjn5aFFymA8ws0Ux1MXgoLxcastCDTx2pSmf3m3ZHqx/J1KnsvRXIwB5rSmsrw0T60YX4qcxj87CfsRQuSxLPWk2kgO4Ct2XnKjMDj/lK5mzbDEr3d1QK8Sze+nxqfq46+XqQSnLHYXbP9JBTyNQKv6gDvU+pEOT8ZxHEGkxgoHxbfS4f883gSQFwjM93YLSR8HRsF057pj6pMwrQBajbLaAeO550JshTHPN/OmAy3/VSlQ==</d:Value>
<d:Description>Certificate description</d:Description>
<d:Thumbprint>8044E2A478067D4F8867BB57A11006C1799A611D</d:Thumbprint>
<d:ExpiryTime m:type="Edm.DateTime">2039-12-31T15:59:59</d:ExpiryTime>
<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://waplabvm4: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");
//ADDED CREDS
NetworkCredential networkCreds = new NetworkCredential("cdmlab\\cdmlabuser", "!!123abc");
((DataServiceContext)SMAService).Credentials = networkCreds;
// This is used here to suppress/ignore certificate errors when using test certificates.
// You can remove this section if you are using trusted certificates.
ServicePointManager.ServerCertificateValidationCallback = new RemoteCertificateValidationCallback(delegate {return true;});
try
{
// Initialize variables to specify certificate values = path and password are required to instantiate the x509 certificate instance.
string certificateName = "Test Certificate";
string certificatePath = "c:\\sma\\certs\\fabrikam.cer";
string certificatePassword = "password"; // SecureString password
string certificateDescription = "Certificate description";
// Create a x509 certificate instance to work with.
var x509Certificate = new X509Certificate2(certificatePath, certificatePassword, X509KeyStorageFlags.PersistKeySet | X509KeyStorageFlags.Exportable);
// Create a new certificate instance.
var testCertificate = new Certificate();
// Populate certificate properties with values.
testCertificate.Name = certificateName;
testCertificate.RawValue = Convert.ToBase64String(x509Certificate.Export(X509ContentType.SerializedCert, certificatePassword));
testCertificate.Thumbprint = x509Certificate.Thumbprint;
testCertificate.ExpiryTime = Convert.ToDateTime(x509Certificate.GetExpirationDateString(), CultureInfo.CurrentCulture);
testCertificate.Description = certificateDescription;
// Add the new certificate instance to the Certificates collection.
// Note: This action is queued up until the SaveChanges action is called.
SMAService.AddToCertificates(testCertificate);
// Save all pending actions (client -> server communication initiated).
SMAService.SaveChanges();
Console.ReadKey();
}
catch (Exception ex)
{
throw new ApplicationException("An error occurred during execution.", ex);
}
}
}
}