Partager via


Create (POST) ConnectionFields

Update using the HTTP POST operation.

Code Examples

Request

Method Request URI HTTP Version

POST

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

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/ConnectionFields 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.ConnectionField" scheme="https://schemas.microsoft.com/ado/2007/08/dataservices/scheme" />
  <id />
  <title />
  <updated>2014-05-01T15:54:29Z</updated>
  <author>
    <name />
  </author>
  <content type="application/xml">
    <m:properties>
      <d:ConnectionFieldID m:type="Edm.Guid">00000000-0000-0000-0000-000000000000</d:ConnectionFieldID>
      <d:ConnectionTypeID m:type="Edm.Guid">15161262-331d-486b-af0c-4da540dcd624</d:ConnectionTypeID>
      <d:CreationTime m:type="Edm.DateTime">0001-01-01T00:00:00</d:CreationTime>
      <d:IsEncrypted m:type="Edm.Boolean">false</d:IsEncrypted>
      <d:IsOptional m:type="Edm.Boolean">true</d:IsOptional>
      <d:LastModifiedTime m:type="Edm.DateTime">0001-01-01T00:00:00</d:LastModifiedTime>
      <d:Name>ffe5c256-839c-4f53-ac59-d4cc860a6545</d:Name>
      <d:TenantID m:type="Edm.Guid">00000000-0000-0000-0000-000000000000</d:TenantID>
      <d:Type>String</d:Type>
    </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://157.54.160.158: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://157.54.160.158:9090/00000000-0000-0000-0000-000000000000/ConnectionFields(guid'8c8f34fd-a93a-40fd-9d8a-9f7898f3d9b9')</id>
  <category term="Orchestrator.ResourceModel.ConnectionField" scheme="https://schemas.microsoft.com/ado/2007/08/dataservices/scheme" />
  <link rel="edit" title="ConnectionField" href="ConnectionFields(guid'8c8f34fd-a93a-40fd-9d8a-9f7898f3d9b9')" />
  <link rel="https://schemas.microsoft.com/ado/2007/08/dataservices/related/ConnectionType" type="application/atom+xml;type=entry" title="ConnectionType" href="ConnectionFields(guid'8c8f34fd-a93a-40fd-9d8a-9f7898f3d9b9')/ConnectionType" />
  <title />
  <updated>2014-05-01T15:54:29Z</updated>
  <author>
    <name />
  </author>
  <content type="application/xml">
    <m:properties>
      <d:TenantID m:type="Edm.Guid">00000000-0000-0000-0000-000000000000</d:TenantID>
      <d:ConnectionFieldID m:type="Edm.Guid">8c8f34fd-a93a-40fd-9d8a-9f7898f3d9b9</d:ConnectionFieldID>
      <d:ConnectionTypeID m:type="Edm.Guid">15161262-331d-486b-af0c-4da540dcd624</d:ConnectionTypeID>
      <d:Name>ffe5c256-839c-4f53-ac59-d4cc860a6545</d:Name>
      <d:Type>String</d:Type>
      <d:IsEncrypted m:type="Edm.Boolean">false</d:IsEncrypted>
      <d:IsOptional m:type="Edm.Boolean">true</d:IsOptional>
      <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 ConnectionField.

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://smaserver: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 ConnectionField instance.
                var connectionField = new ConnectionField();

                // Populate properties with values.
                connectionField.Name = Guid.NewGuid().ToString();                
                connectionField.ConnectionTypeID = connectionType.ConnectionTypeID;
                connectionField.IsEncrypted = false;
                connectionField.IsOptional = true;
                connectionField.Type = "String"; 

                // Add the new ConnectionField instance to the ConnectionField collection.
                // Note: This action is queued up until the SaveChanges action is called.
                SMAService.AddToConnectionFields(connectionField);

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

ConnectionField
ConnectionFields