Search

The Search API lets you search for one or more ticket types in the application. Additional parameters allow you to choose which fields to search, limit the number of results, or page through results.

Tip: The Search API supports basic authentication. For more information, please see Creating a Request > Headers.

Action

Method

URL

Description

Search Entities

GET

api/{entitytype}/search?searchtext={searchtext}
&autocomplete={autocomplete}
&pagesize={pagesize}
&page={page}

Returns the match(es) for the specified entity type and query.

Search Entities by Type

GET

api/types/search?entitytypes={entitytypes[0]}
&entitytypes={entitytypes[1]}
&searchtext={searchtext}
&autocomplete={autocomplete}
&pagesize={pagesize}
&page={page}

Returns the match(es) for the specified entity types and query.

 

Search Entities

Searching takes plain text input and returns a list of matches.

Request Information

URL

api/{entitytype}/search?searchtext={searchtext}&autocomplete={autocomplete}&pagesize={pagesize}&page={page}

Parameter

Description

Type

Example

Additional Information

entitytype

The type of entity to search. Use "All" to search across all types.

String

/IncidentRequest/

Required.

searchtext

The search query.

String

searchtext=printer

Required.

autocomplete

If true, only the summary field will be searched.

Boolean

autocomplete=true

Defaults to false. This should only be set to true if you are processing a high volume of queries.

pagesize

The number of results to return.

Integer

pagesize=15

Defaults to 10.

page

If the total results exceeds pagesize, this returns the corresponding page.

Integer

page=4

Defaults to 1.

Method

POST

Header Parameters

Parameter

Description

Type

Example

Additional Information

sessionid

The encrypted session ID.

String

ap9pYaaBK8K5iMNZNC5DtA==

Required if not using Basic Authentication.

Sample Request

URL: https://application-server/cgrestapi/api/incidentrequest/search?searchtext=mysearch&autocomplete=true&pagesize=10&page=2

Header: sessionid: EhbNKWgPZNJnHRPWJ3PfvLrtavbL591sfEVzR3Hn/Fs7RCBceNxpWIuhw0iIn8YM

 

Response Information

Body Fields

Field

Description

Type

Example

Additional Information

Oid

The unique ID of the returned item.

Integer

50

 

Status

The status of the item.

String

New

 

SLAStage

The stage that the ticket's SLA is currently in (if applicable).

String

Meets

If not applicable, this field displays null.

ItemId

The reference ID of the item in ChangeGear.

String

IR-0000050

 

Summary

The summary of the item.

String

Incident ticket created with REST API.

 

TicketType

The type of ticket.

String

IIncidentRequest

 

Priority

The priority of the item.

String

1 - Critical

 

DueDate

The item's due date

String

2016-08-30T13:30:00-06:00

 

SearchResultDetails

JSON-encoded object representing the details of the search performed.

String

[See Sample Response]

 

eTag

The version of the item. For more information, see Update an Item in the Entity API.

Integer

5

Required for updating entities.

Sample Response

[

{

"Oid": 50,

"Status": "New",

"SLAStage": "Meets",

"ItemId": "IR-0000001",

"Summary": "Incident ticket created with REST API.",

"TicketType": "IIncidentRequest",

"Priority": "1 - Critical",

"DueDate": "2015-03-09T23:59:00-06:00",

"FullTextSearchString": null,

Generate real data

"SearchResultDetails": "{\"MatchDetails\":[{\"ID\":50,\"Field\":\"Summary\",\"Value\":[\"<em>Incident</em> ticket created with REST API.\"]}]}",

"eTag": 3

}

]

 

Search Entities by Type

Searching takes plain text input and returns a list of matches. Searching by type allows you to specify one or more modules to include in the search.

Request Information

URL

api/types/search?entitytypes={entitytypes[0]}&entitytypes={entitytypes[1]}&searchtext={searchtext}&autocomplete={autocomplete}&pagesize={pagesize}&page={page}

Parameter

Description

Type

Example

Additional Information

entitytypes

The entity types to include in the search.

Array of strings

entitytypes=incidentrequest
&entitytypes=problemreport

Required. You can specify multiple types by specifying multiple parameters.

searchtext

The search query.

String

searchtext=printer

Required.

autocomplete

If true, only the summary field will be searched.

Boolean

autocomplete=true

Defaults to false. This should only be set to true if you are processing a high volume of queries.

pagesize

The number of results to return.

Integer

pagesize=15

Defaults to 10.

page

If the total results exceeds pagesize, this returns the corresponding page.

Integer

page=4

Defaults to 1.

Method

POST

Header Parameters

Parameter

Description

Type

Example

Additional Information

sessionid

The encrypted session ID.

string

ap9pYaaBK8K5iMNZNC5DtA==

Required.

Sample Request

URL: https://changegear-server/CGRestAPI/api/types/search?entitytypes=incidentrequest&entitytypes=problemreport&searchtext=mysearch

Header: sessionid: EhbNKWgPZNJnHRPWJ3PfvLrtavbL591sfEVzR3Hn/Fs7RCBceNxpWIuhw0iIn8YM

 

Response Information

Body Fields

Field

Description

Type

Example

Additional Information

Oid

The unique ID of the returned item.

Integer

50

 

Status

The status of the item.

String

New

 

SLAStage

The stage that the item's SLA is currently in (if applicable).

String

Meets

If not applicable, this field displays null.

ItemId

The reference ID of the item in ChangeGear.

String

IR-0000050

 

Summary

The summary of the item.

String

Incident ticket created with REST API.

 

TicketType

The entity type of the item.

String

IIncidentRequest

 

Priority

The priority of the item (if applicable).

String

1 - Critical

 

DueDate

The item's due date (if applicable).

String

2016-08-30T13:30:00-06:00

 

SearchResultDetails

A JSON-encoded representation of the search result, including the value matched.

String

[See Sample Response]

 

eTag

The version of the item. For more information, see Update an Item in the Entity API.

Integer

5

Required for updating entities.

Sample Response

[

{

"Oid": 50,

"Status": "New",

"SLAStage": "Meets",

"ItemId": "IR-0000001",

"Summary": "Incident ticket created with REST API.",

"TicketType": "IIncidentRequest",

"Priority": "1 - Critical",

"DueDate": "2015-03-09T23:59:00-06:00",

"FullTextSearchString": null,

Generate real data

"SearchResultDetails": "{\"MatchDetails\":[{\"ID\":50,\"Field\":\"Summary\",\"Value\":[\"<em>Incident</em> ticket created with REST API.\"]}]}",

"eTag": 3

}

]