/// <summary> /// Handle HTTPPUT request coming in from the client after successful Authentication /// </summary> /// <param name="request"></param> /// <returns>HTTPRespose code with succees/failure</returns> public HttpResponseMessage Put(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; surveyanswerModel.SurveyQuestionAnswerListField = keyvalupair; var Result = _isurveyAnswerRepository.Update(surveyanswerModel, responseId); if (Result.SurveyResponseID != null) { if (Result.Status == "Created") { var response = Request.CreateResponse <PreFilledAnswerResponse>(System.Net.HttpStatusCode.Created, Result);//201 Created Success with response body. string uri = Url.Link("DefaultApi", new { id = Result.SurveyResponseID }); response.Headers.Location = new Uri(uri); return(response); } else { var response = Request.CreateResponse <PreFilledAnswerResponse>(System.Net.HttpStatusCode.OK, Result);//200 OK Success with response body. string uri = Url.Link("DefaultApi", new { id = Result.SurveyResponseID }); response.Headers.Location = new Uri(uri); return(response); } } else { var response = Request.CreateResponse(HttpStatusCode.Forbidden, "Response not generated");// The requested operation is not permitted for the user. This error can also be caused by ACL failures, or business rule or data policy constraints. 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); } }