PUT api/{entitytype}/{id}
Request Information
URI Parameters
Name | Description | Type | Additional information |
---|---|---|---|
entitytype | string |
Required |
|
id | integer |
Required |
Body Parameters
Dictionary of string [key] and Object [value]Request Formats
application/json
Sample:
{eTag: 97,Summary:'New Summary'}
application/x-www-form-urlencoded
Sample:
{"sample string 1":{},"sample string 3":{}}
Response Information
HttpResponseMessageName | Description | Type | Additional information |
---|---|---|---|
Version | Version |
None. |
|
Content | HttpContent |
None. |
|
StatusCode | HttpStatusCode |
None. |
|
ReasonPhrase | string |
None. |
|
Headers | Collection of Object |
None. |
|
RequestMessage | HttpRequestMessage |
None. |
|
IsSuccessStatusCode | boolean |
None. |
Example Code in C#
//REQUEST int id = id of the ticket to update string type = "changemanagementticket" string uri = string.Format("http://localhost/restapi/api/{0}/{1}",id,type); HttpWebRequest webRequest = (System.Net.HttpWebRequest)System.Net.WebRequest.Create(uri); //Assumption: CGRestAPI is configured to use WIA. Otherwise, sessionid needs to be sent in the headers webRequest.Credentials = CredentialCache.DefaultCredentials; webRequest.Method = "POST"; webRequest.ContentType = "application/json"; var ticketData = JsonConvert.SerializeObject(new { Summary: 'New Summary', eTag: 11 //this is returned on the get of an item. }, Formatting.Indented); using (Stream dataStream = webRequest.GetRequestStream()) { using (var streamWriter = new StreamWriter(dataStream)) { using (var writer = new JsonTextWriter(streamWriter)) { writer.WriteRaw(ticketData); } } } HttpWebResponse httpWebResponse = (System.Net.HttpWebResponse)webRequest.GetResponse(); //RESPONSE HttpWebResponse httpWebResponse = (System.Net.HttpWebResponse)webRequest.GetResponse(); Stream responseStream = httpWebResponse.GetResponseStream(); using (var streamReader = new StreamReader(responseStream)) { IDictionary responseData = new Hashtable(); var result = JsonConvert.DeserializeObject(streamReader.ReadToEnd()); if (result != null) { //do something here } }