Share via


Create (POST) ConnectionTypes

Update using the HTTP POST operation.

Important

After creating a ConnectionType instance, it’s necessary to update the IsBeingCreated property from true to false. This is required after initial creation, before using the ConnectionType instance. See the Update (PUT/MERGE) ConnectionTypes topic for more information.

Code Examples

Request

Method Request URI HTTP Version

POST

HTTPS://<HOST>:<PORT>/00000000-0000-0000-0000-000000000000/ConnectionTypes

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/ConnectionTypes 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.ConnectionType" scheme="https://schemas.microsoft.com/ado/2007/08/dataservices/scheme" />
  <id />
  <title />
  <updated>2014-04-06T17:21:27Z</updated>
  <author>
    <name />
  </author>
  <content type="application/xml">
    <m:properties>
      <d:ConnectionTypeID m:type="Edm.Guid">00000000-0000-0000-0000-000000000000</d:ConnectionTypeID>
      <d:CreationTime m:type="Edm.DateTime">0001-01-01T00:00:00</d:CreationTime>
      <d:IsBeingCreated m:type="Edm.Boolean">false</d:IsBeingCreated>
      <d:LastModifiedTime m:type="Edm.DateTime">0001-01-01T00:00:00</d:LastModifiedTime>
      <d:Name>Test ConnectionType Name</d:Name>
      <d:TenantID m:type="Edm.Guid">00000000-0000-0000-0000-000000000000</d:TenantID>
    </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/ConnectionTypes(guid'f3af8c83-1ae7-4e33-9282-b0aef45b82b0')</id>
  <category term="Orchestrator.ResourceModel.ConnectionType" scheme="https://schemas.microsoft.com/ado/2007/08/dataservices/scheme" />
  <link rel="edit" title="ConnectionType" href="ConnectionTypes(guid'f3af8c83-1ae7-4e33-9282-b0aef45b82b0')" />
  <link rel="https://schemas.microsoft.com/ado/2007/08/dataservices/related/ConnectionFields" type="application/atom+xml;type=feed" title="ConnectionFields" href="ConnectionTypes(guid'f3af8c83-1ae7-4e33-9282-b0aef45b82b0')/ConnectionFields" />
  <link rel="https://schemas.microsoft.com/ado/2007/08/dataservices/related/Connections" type="application/atom+xml;type=feed" title="Connections" href="ConnectionTypes(guid'f3af8c83-1ae7-4e33-9282-b0aef45b82b0')/Connections" />
  <title />
  <updated>2014-04-06T17:21:28Z</updated>
  <author>
    <name />
  </author>
  <content type="application/xml">
    <m:properties>
      <d:TenantID m:type="Edm.Guid">00000000-0000-0000-0000-000000000000</d:TenantID>
      <d:ConnectionTypeID m:type="Edm.Guid">f3af8c83-1ae7-4e33-9282-b0aef45b82b0</d:ConnectionTypeID>
      <d:Name>ConnectionType Name</d:Name>
      <d:IsBeingCreated m:type="Edm.Boolean">false</d:IsBeingCreated>
      <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 ConnectionType.

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");

            try
            {
                // Create a new ConnectionType instance.
                var connectionType = new ConnectionType();

                // Populate various properties with values.
                connectionType.Name = "ConnectionType Name";
 
                // Add the new ConnectionType instance to the ConnectionType collection.
                // Note: This action is queued up until the SaveChanges action is called.
                SMAService.AddToConnectionTypes(connectionType);

                // Save all pending actions (client -> server communication initiated).
                SMAService.SaveChanges();

            }
            catch (Exception ex)
            {
                throw new ApplicationException("An error occurred during execution.", ex);
            }
        }                 
    }
}

See Also

Concepts

ConnectionType
ConnectionTypes