public static ContentRequest ParseJson(string json) { var jobject = JObject.Parse(json); var id = (string)jobject.SelectToken("id"); var title = (string)jobject.SelectToken("title"); var contentType = (string)jobject.SelectToken("content_type"); DivvyLogManager.LogRequest("JSON parsed successfully."); var contentTypePrefix = "Content Type: "; if (contentType != null && contentType.StartsWith(contentTypePrefix)) { contentType = new String(contentType.Skip(contentTypePrefix.Length).ToArray()); } var contentRequest = new ContentRequest() { Id = int.Parse(id), Title = title, ContentType = contentType, Description = (string)jobject.SelectToken("description"), Calendar = (string)jobject.SelectToken("calendar"), Owner = (string)jobject.SelectToken("owner_member") }; DivvyLogManager.LogRequest("Parsed Values", contentRequest); return(contentRequest); }
private string GetRequestBody() { // We retrieve and parse this manually so we can run events on it... var bodyStream = new StreamReader(Request.InputStream); bodyStream.BaseStream.Seek(0, SeekOrigin.Begin); var bodyText = bodyStream.ReadToEnd(); DivvyLogManager.LogRequest($"Request Body Retrieved ({bodyText.Length} byte(s). {bodyText})"); return(bodyText); }