次の方法で共有


Read (GET) JobContexts

Read using the HTTP GET operation.

Code Examples

Request

Method Request URI HTTP Version

GET

HTTPS://<HOST>:<PORT>/00000000-0000-0000-0000-000000000000/JobContexts(guid'<GUID>')

HTTP/1.1

Request URI Parameters

URI Parameter Description

GUID

Required. The unique identifier value (JobContextID) for a JobContext entity.

Request URI Example

Example URI

GET https://sma-server:9090/00000000-0000-0000-0000-000000000000/JobContexts(guid'96c9a9ec-c60f-4f9d-8124-f33abb9176b8') 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 GET operation has no request body.

Response

Response Codes

Response Code Description

HTTP/1.1 200 OK

Successful HTTP request.

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/JobContexts(guid'96c9a9ec-c60f-4f9d-8124-f33abb9176b8')</id>
  <category term="Orchestrator.ResourceModel.JobContext" scheme="https://schemas.microsoft.com/ado/2007/08/dataservices/scheme" />
  <link rel="edit" title="JobContext" href="JobContexts(guid'96c9a9ec-c60f-4f9d-8124-f33abb9176b8')" />
  <link rel="https://schemas.microsoft.com/ado/2007/08/dataservices/related/RunbookVersion" type="application/atom+xml;type=entry" title="RunbookVersion" href="JobContexts(guid'96c9a9ec-c60f-4f9d-8124-f33abb9176b8')/RunbookVersion" />
  <link rel="https://schemas.microsoft.com/ado/2007/08/dataservices/related/JobParameters" type="application/atom+xml;type=feed" title="JobParameters" href="JobContexts(guid'96c9a9ec-c60f-4f9d-8124-f33abb9176b8')/JobParameters" />
  <link rel="https://schemas.microsoft.com/ado/2007/08/dataservices/related/Schedule" type="application/atom+xml;type=entry" title="Schedule" href="JobContexts(guid'96c9a9ec-c60f-4f9d-8124-f33abb9176b8')/Schedule" />
  <title />
  <updated>2014-04-06T00:49:11Z</updated>
  <author>
    <name />
  </author>
  <content type="application/xml">
    <m:properties>
      <d:JobContextID m:type="Edm.Guid">96c9a9ec-c60f-4f9d-8124-f33abb9176b8</d:JobContextID>
      <d:RunbookVersionID m:type="Edm.Guid">4a4bd402-35ed-4c6e-9cfe-4af61364cc58</d:RunbookVersionID>
      <d:TenantID m:type="Edm.Guid">00000000-0000-0000-0000-000000000000</d:TenantID>
      <d:ScheduleID m:type="Edm.Guid" m:null="true" />
    </m:properties>
  </content>
</entry>

Code Examples

The following example searches for a specific JobContext, identified by the JobContextID (a unique guid value).

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
            {
                // Listing the JobContext for a specific Job.
                // Identify a specific job instance to search for.
                System.Guid jobID = new Guid("aafdeea4-5f0a-4223-9d20-01a33df2ed97");

                // Query for the specific activity instance identified by JobID.
                var job = SMAService.Jobs.Where(r => r.JobID == jobID).FirstOrDefault();

                // Query for the JobContext associated with the specific job instance.
                var jobContexts = SMAService.JobContexts.Where(r => r.JobContextID == job.JobContextID);

                // Output select properties of the instance to the console.
                Console.WriteLine(" ");
                Console.WriteLine("Job ID              : {0}", job.JobID);
                Console.WriteLine("Job Context ID      : {0}", jobContext.JobContextID);
                Console.WriteLine("RunbookVersionID    : {0}", jobContext.RunbookVersionID);
                Console.WriteLine("Schedule ID         : {0}", jobContext.ScheduleID);       

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

See Also

Concepts

JobContext
JobContexts