コード例 #1
0
        /// <summary>
        /// Retrieve a given survey's metadata.
        /// Notes
        ///     •Surveys with over 200 survey pages will not be returned
        ///     •Surveys with over 1000 questions will not be returned
        /// Endpoint : https://api.surveymonkey.net/v2/surveys/get_survey_details?api_key=your_api_key
        /// Example Request
        ///     curl -H 'Authorization:bearer XXXYYYZZZ' -H 'Content-Type: application/json' https://api.surveymonkey.net/v2/surveys/get_survey_details/?api_key=your_api_key --data-binary '{"survey_id":"100399456"}'
        /// </summary>
        private void BtnGetSurveyDetails_Click(object sender, EventArgs e)
        {
            GetSurveyDetailsResponse surveyDetails;
            BasicRequestData         brd        = new BasicRequestData();
            SurveyQuestionView       surveyView = new SurveyQuestionView();

            if (txtSurveyID.Text.Trim().Length > 0)
            {
                brd.SurveyID = txtSurveyID.Text;
            }
            else
            {
                brd.SurveyID = null;
            }

            if (brd.SurveyID == null)
            {
                MessageBox.Show("no survey id specified.  Going to get error back.");
            }

            surveyDetails = SurveyRequest.GetSurveyDetails(brd);

            lblStatus.Text   = surveyDetails.Status.ToString();
            lblErrorMsg.Text = surveyDetails.ErrorMessage;

            try
            {
                if (chkSurveyAnswers.Checked)
                {
                    surveyView.LoadSurvey(surveyDetails);
                    dgvSurveyList.DataSource = surveyView.SurveyWithAnswers;
                }
                else
                {
                    List <SurveyTInfo> sdrList = new List <SurveyTInfo>();
                    sdrList.Add(surveyDetails.SurveyDetailsResult);
                    dgvSurveyList.DataSource = sdrList;
                }
            }
            catch { } // do nothing
        }