POST api/user/logout
Request Information
URI Parameters
None.
Body Parameters
None.
Request Formats
application/json
Sample:
{username: 'hq\apitest',password: 'test'}
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. |
Response Formats
application/json
Sample:
{sessionId: 'EhbNKWgPZNJnHRPWJ3PfvLrtavbL591sfEVzR3Hn/Fs7RCBceNxpWIuhw0iIn8YM',userId: '123'}
application/x-www-form-urlencoded
Sample:
{"sample string 1":"sample string 2","sample string 3":"sample string 4"}
Example Code in C#
//REQUEST string uri = "http://localhost/restapi/api/authenticate/user"; HttpWebRequest webRequest = (System.Net.HttpWebRequest)System.Net.WebRequest.Create(uri); //Assumption: CGRestAPI is configured to use WIA webRequest.Credentials = CredentialCache.DefaultCredentials; webRequest.Method = "POST"; webRequest.ContentType = "application/json"; var loginData = JsonConvert.SerializeObject(new { username = "hq\\apitest", password = "apitest" }, Formatting.Indented); using (Stream dataStream = webRequest.GetRequestStream()) { using (var streamWriter = new StreamWriter(dataStream)) { using (var writer = new JsonTextWriter(streamWriter)) { writer.WriteRaw(loginData); } } } 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) { foreach (JProperty prop in ((Newtonsoft.Json.Linq.JObject)result).Properties()) { responseData[prop.Name] = ((Newtonsoft.Json.Linq.JValue)(prop.Value)).Value; } string sessionId = responseData["sessionId"].ToString()); string userId = responseData["userId"].ToString()); } }