public async Task <IActionResult> Post() { string rawBody; using (var reader = new StreamReader(Request.Body)) { rawBody = await reader.ReadToEndAsync(); if (!_verifier.Verify(Request.Headers, rawBody)) { return(BadRequest()); } } var eventWrapper = JsonConvert.DeserializeObject <EventWrapperRequest>(rawBody, _defaultSlackSerializerSettings); // url verification for slack // https://api.slack.com/events-api#request_url_configuration__amp__verification if (eventWrapper.Type.Equals("url_verification")) { return(Ok(eventWrapper.Challenge)); } if (ModelState.IsValid) { // It's necessary to confirm request immediately // In order to prevent automatic disabling // https://api.slack.com/events-api#responding_to_events await Task.Run(() => { _eventService.ProcessRequest(eventWrapper); }); } return(Ok()); }
public async Task <IActionResult> Post() { string rawBody; using (var reader = new StreamReader(Request.Body)) { rawBody = await reader.ReadToEndAsync(); } var decoded = WebUtility.UrlDecode(rawBody); var jsonString = decoded.Split("=", 2).ElementAt(1); if (!_verifier.Verify(Request.Headers, rawBody)) { return(BadRequest()); } await _routingService.Route(jsonString); return(Ok()); }