GET api/{entitytype}/search?searchtext={searchtext}&autocomplete={autocomplete}&pagesize={pagesize}&page={page}
Returns the match for the specified entity type or across all types if entitytype is "all"
Request Information
URI Parameters
Name | Description | Type | Additional information |
---|---|---|---|
entitytype |
Type of the entity to search on. Example: all/incidentrequest/problem/KB etc |
string |
Required |
searchtext |
Text to search |
string |
Required |
autocomplete |
If true, only summary field will be searched. This should be set to true only for typeahead searches |
boolean |
Default value is False |
pagesize |
Number of results that should be returned, defaults to 10 |
integer |
Default value is 10 |
page |
Page number |
integer |
Default value is 1 |
Body Parameters
None.
Response Information
List of objects
Response Formats
application/json
Sample:
[ { "Oid": 1, "Status": "New", "ItemId": "IR-0000001", "Summary": "test", "Priority": "1 - Critical", "DueDate": "2015-03-09T23:59:00-06:00" }, { "Oid": 2, "IsDeleted": false, "Status": "Unsubmitted", "ItemId": "IR-0000002", "Summary": "test printer", "Priority": "1 - Critical", "DueDate": "2015-03-10T23:59:00-06:00" } ]
application/x-www-form-urlencoded
Sample:
{}
Example Code in C#
//REQUEST string sessionId = set to the sessionId that was received on login; string searchtext = text to search string entitytype = can be 'Incident','KB', etc int pagesize = 10; int page = 1; string uri = string.format("http://localhost/restapi/api/{0}/search?searchtext={1}&pagesize={2}&page={3}", entitytype,searchtext, pagesize,page); HttpWebRequest webRequest = (System.Net.HttpWebRequest)System.Net.WebRequest.Create(uri); //Assumption: CGRestAPI is configured to use WIA webRequest.Credentials = CredentialCache.DefaultCredentials; webRequest.Method = "GET"; webRequest.ContentType = "application/json"; webRequest.Headers.Add("sessionid", sessionId); HttpWebResponse httpWebResponse = (System.Net.HttpWebResponse)webRequest.GetResponse(); Stream responseStream = httpWebResponse.GetResponseStream(); using (var streamReader = new StreamReader(responseStream)) { var result = JsonConvert.DeserializeObject(streamReader.ReadToEnd()); if (result != null && result is Newtonsoft.Json.Linq.JArray) { //do something with the result } }