/// <summary> /// Handle HTTPDELETE request coming in from the client after successful Authentication /// </summary> /// <param name="request"></param> /// <returns>HTTPRespose code with succee/failure</returns> public HttpResponseMessage Delete(HttpRequestMessage request) { Dictionary <string, string> keyvalupair = new Dictionary <string, string>(); var value = request.Content.ReadAsStringAsync().Result; var settings = new JsonSerializerSettings { NullValueHandling = NullValueHandling.Ignore, MissingMemberHandling = MissingMemberHandling.Ignore }; try { keyvalupair = JsonConvert.DeserializeObject <Dictionary <string, string> >(value, settings); } catch (Exception ex) { var response = Request.CreateResponse(HttpStatusCode.UnsupportedMediaType, ex.Message.ToString());//415 Unsupported media type The endpoint does not support the format of the request body. return(response); } string responseId; SurveyAnswerModel surveyanswerModel = new SurveyAnswerModel(); surveyanswerModel.SurveyId = _isurveyAnswerRepository.SurveyId; surveyanswerModel.OrgKey = _isurveyAnswerRepository.OrgKey; surveyanswerModel.PublisherKey = _isurveyAnswerRepository.PublisherKey; var item = keyvalupair.Where(x => x.Key.ToLower() == "responseid" || x.Key.ToLower() == "id").FirstOrDefault(); // if (keyvalupair.TryGetValue("ResponseId", out ResponseId)) if (item.Value != null) { responseId = item.Value; try { _isurveyAnswerRepository.Remove(responseId); } catch (Exception ex) { var exresponse = Request.CreateResponse(HttpStatusCode.Forbidden, "Response does not exist");//The request has not succeeded. The information returned with the response is dependent on the method used in the request. return(exresponse); } var response = Request.CreateResponse(HttpStatusCode.OK, "Response Deleted.");//The request has succeeded. The information returned with the response is dependent on the method used in the request. return(response); } else { var response = Request.CreateResponse(HttpStatusCode.UnsupportedMediaType, "Response not generated");//415 Unsupported media type The endpoint does not support the format of the request body. return(response); } }