/// <summary> /// Takes a list of respondent ids and returns the responses that correlate to them.To be used with 'get_survey_details' /// Notes /// Surveys with over 500,000 reponses are not available via the API currently /// Text responses returned are truncated after 32,768 characters /// Max number of respondents per call is 100 /// Endpoint : https://api.surveymonkey.net/v2/surveys/get_responses?api_key=your_api_key /// Example Request /// curl -H 'Authorization:bearer XXXYYYZZZ' -H 'Content-Type: application/json' https://api.surveymonkey.net/v2/surveys/get_responses/?api_key=your_api_key --data-binary '{"survey_id":"103994756", "respondent_ids": ["2503019027", "2500039028", "2500039029", "2503019064"]}' /// </summary> public GetResponsesResponse GetResponses(BasicRequestData requestData) { JsonResponse = MakeApiRequest(GET_RESPONSES, requestData); GetResponsesResponse surveyList = JsonConvert.DeserializeObject <GetResponsesResponse>(JsonResponse); return(surveyList); }
/// <summary> /// Adds new ResponseResults to the existing list /// </summary> /// <param name="responses">batch of responses to a survey</param> /// <param name="brd"></param> /// <param name="isProcessed">Whether the first hundred responses have been processed</param> /// <returns></returns> private GetResponsesResponse GetRespondenses(GetResponsesResponse responses, BasicRequestData brd, bool isProcessed) { if (!isProcessed) { return(SurveyRequest.GetResponses(brd)); } else { GetResponsesResponse temp = SurveyRequest.GetResponses(brd); List <GetResponsesResult> newResponsesResultList = new List <GetResponsesResult>(); newResponsesResultList.AddRange(responses.ResponseResultList); newResponsesResultList.AddRange(temp.ResponseResultList); responses.ResponseResultList = newResponsesResultList.ToArray(); return(responses); } }
public ActionResult <GetResponsesResponse> GetResponsesForPeriod([FromBody] GetResponsesForPeriodRequest request) { try { if (!TryValidateModel(request)) { return(StatusCode(400)); } var responses = _service.GetResponsesForPeriod(request); var response = new GetResponsesResponse { Responses = responses }; return(Ok(response)); } catch (Exception ex) { return(StatusCode(500)); } }
/// <summary> /// Returns a summary of how respondents answered each question, including counts and average ratings /// </summary> private void BtnGetResponseSummary_Click(object sender, EventArgs e) { GetSurveyDetailsResponse surveyDetails; GetResponsesResponse responses; GetRespondentListResponse respondent; BasicRequestData brd = GetRequestFields(); brd.PageSize = 1000; // get all respondents SurveyQuestionView surveyView = new SurveyQuestionView(); ResponseView responseView = new ResponseView(); if (brd.SurveyID == null) { MessageBox.Show("no survey id specified. Going to get error back."); } try { surveyDetails = SurveyRequest.GetSurveyDetails(brd); respondent = SurveyRequest.GetRespondentListFull(brd); List <string> respondantID = new List <string>(); bool isProcessed = false; responses = new GetResponsesResponse(); foreach (RespondentInfo rInfo in respondent.RespondantListResult.RespondantList) { respondantID.Add(rInfo.RespondentID); // maximum number of respondents that can be processed is 100 if (respondantID.Count == 100) { brd.RespondentIDList = respondantID.ToArray(); responses = GetRespondenses(responses, brd, isProcessed); isProcessed = true; respondantID.Clear(); } } if (respondantID.Count > 0) { brd.RespondentIDList = respondantID.ToArray(); } responses = GetRespondenses(responses, brd, isProcessed); surveyView.LoadSurvey(surveyDetails); responseView.LoadResponseSummary(responses.ResponseResultList, surveyView); lblStatus.Text = respondent.Status.ToString(); lblErrorMsg.Text = respondent.ErrorMessage; try { dgvSurveyList.DataSource = responseView.SurveyWithAnswers; //respondent.ResponseResultList; // update database with survey results } catch { } // do nothing } catch { MessageBox.Show("ERROR with respondants specified. No data submitted to SurveyMonkey"); } }