private JObject GetPayload(HttpRequestBase request) { JObject payload; // we don't care about content type, just let it choked if (request.Form.Count > 0) { string json = request.Form["payload"]; if (String.IsNullOrEmpty(json)) { json = request.Form[0]; } payload = JsonConvert.DeserializeObject <JObject>(json); } else { using (JsonTextReader reader = new JsonTextReader(new StreamReader(request.GetInputStream()))) { payload = JObject.Load(reader); } } if (payload == null) { throw new FormatException(Resources.Error_EmptyPayload); } if (_tracer.TraceLevel >= TraceLevel.Verbose) { TracePayload(payload); } return(payload); }