C# Example: Get an Incident

The following example shows how to get an Incident using C#.
Important: Run Swagger Code Generation before attempting to modify the code so that you do not receive reference errors. Refer to Using Swagger Code Generation for the procedure.
using IO.Swagger.Api;

namespace Trebuchet.WebApi.IntegrationTests.ExamplesForCustomers.GetanObject
{
    public class GetAnObject
    {
        public void GetABusinessObject()
        {
            //Get an access token using CSM credentials
            var serviceApi = new ServiceApi("http://your server/CherwellApi/");
            var tokenResponse = serviceApi.ServiceToken("password",
                "your client id", null, "CSDAdmin", "CSDAdmin", null,
                "Internal");

            //Create a new Business Object api object and add the default header
            var businessObjectApi = new BusinessObjectApi("http://your server/CherwellApi/");
            businessObjectApi.Configuration.AddDefaultHeader("Authorization",
                "Bearer " + tokenResponse.AccessToken);

            //Get the Business Object summary by name.  This returns the Business Object ID
            var businessObjectSummaryByName =
                businessObjectApi.BusinessObjectGetBusinessObjectSummaryByNameV1("Incident");

            //Get the Business Object by public ID
            var readResponse =
                businessObjectApi.BusinessObjectGetBusinessObjectByPublicIdV1(
                    businessObjectSummaryByName[0].BusObId, "102667");
        }
    }
}
© Copyright 2018 Cherwell Software, LLC. All rights reserved.