Share via


Create (POST) Connections

Update using the HTTP POST operation.

Code Examples

Request

Method Request URI HTTP Version

POST

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

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/Connections 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.Connection" scheme="https://schemas.microsoft.com/ado/2007/08/dataservices/scheme" />
  <id />
  <title />
  <updated>2014-04-06T19:39:42Z</updated>
  <author>
    <name />
  </author>
  <content type="application/xml">
    <m:properties>
      <d:ConnectionID m:type="Edm.Guid">00000000-0000-0000-0000-000000000000</d:ConnectionID>
      <d:ConnectionTypeID m:type="Edm.Guid">3921d613-e650-46da-bf19-1700c09f2d33</d:ConnectionTypeID>
      <d:CreationTime m:type="Edm.DateTime">0001-01-01T00:00:00</d:CreationTime>
      <d:Description>Test Connection Description</d:Description>
      <d:LastModifiedTime m:type="Edm.DateTime">0001-01-01T00:00:00</d:LastModifiedTime>
      <d:Name>Test Connection 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

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/Connections(guid'af2990f4-1f47-44c5-9c0f-90c92635c193')</id>
  <category term="Orchestrator.ResourceModel.Connection" scheme="https://schemas.microsoft.com/ado/2007/08/dataservices/scheme" />
  <link rel="edit" title="Connection" href="Connections(guid'af2990f4-1f47-44c5-9c0f-90c92635c193')" />
  <link rel="https://schemas.microsoft.com/ado/2007/08/dataservices/related/ConnectionFieldValues" type="application/atom+xml;type=feed" title="ConnectionFieldValues" href="Connections(guid'af2990f4-1f47-44c5-9c0f-90c92635c193')/ConnectionFieldValues" />
  <link rel="https://schemas.microsoft.com/ado/2007/08/dataservices/related/ConnectionType" type="application/atom+xml;type=entry" title="ConnectionType" href="Connections(guid'af2990f4-1f47-44c5-9c0f-90c92635c193')/ConnectionType" />
  <title />
  <updated>2014-04-06T19:39:43Z</updated>
  <author>
    <name />
  </author>
  <content type="application/xml">
    <m:properties>
      <d:TenantID m:type="Edm.Guid">00000000-0000-0000-0000-000000000000</d:TenantID>
      <d:ConnectionID m:type="Edm.Guid">af2990f4-1f47-44c5-9c0f-90c92635c193</d:ConnectionID>
      <d:ConnectionTypeID m:type="Edm.Guid">3921d613-e650-46da-bf19-1700c09f2d33</d:ConnectionTypeID>
      <d:Name>Test Connection Name</d:Name>
      <d:Description>Test Connection 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 Connection.

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
            {
                // Identify the connection type for this connection using the ConnectionTypeID value. 
                System.Guid connectionTypeID = new Guid("3921d613-e650-46da-bf19-1700c09f2d33");

                // Create a new connection instance.
                var testConnection = new Connection();
                                
                // Poputlate various properties with values.
                testConnection.Name = "Test Connection Name";
                testConnection.Description = "Test Connection Description";
                testConnection.ConnectionTypeID = connectionTypeID;
                
                // Add the new connection instance to the Connections collection.
                // Note: This action is queued up until the SaveChanges action is called.
                SMAService.AddToConnections(testConnection);

                // 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

Connection
Connections