//You may wish to replace this code with your preferred library for posting and receiving JSON data. private static Event MakeWebRequest(string requestUrl, GetEventsRequestBody request) { var webRequest = WebRequest.Create(requestUrl) as HttpWebRequest; webRequest.Method = "POST"; webRequest.ContentType = "application/json"; var jsonSerializer = new JavaScriptSerializer(); var requestStr = jsonSerializer.Serialize(request); Debug.WriteLine(requestStr); using (var writer = new StreamWriter(webRequest.GetRequestStream())) { writer.Write(requestStr); writer.Close(); } var response = webRequest.GetResponse() as HttpWebResponse; string jsonResult; using (var reader = new StreamReader(response.GetResponseStream())) { jsonResult = reader.ReadToEnd(); reader.Close(); } Debug.WriteLine(jsonResult); return(jsonSerializer.Deserialize <Event>(jsonResult)); }
// token received from CreateSession/RenewSession API call public Event GetEvents(string token, List <int> _EventID) { var GetEventsRequestBody = new GetEventsRequestBody { RequestHeader = new RequestHeader { Token = token }, EventIds = _EventID }; return(MakeWebRequest(SearchForImagesRequestUrl, GetEventsRequestBody)); }