使用SurveyMonkey .Net包装器

时间:2016-10-29 19:16:19

标签: .net surveymonkey

我想使用SurveyMonkey API来获取问题& .NET应用程序中的答案,我正在起诉.Net包装器。 我可以获得有关调查的一般信息,例如(surveyId,问题数量等),但是当我尝试获取收集器或问题或响应或任何其他obejct时,我会收到错误,说明这些对象为空。 这是我要做的一段代码

string apiKey = "key";
string token ="token";
var sm = new SurveyMonkeyApi(apiKey, token);
List<Survey> surveys = sm.GetSurveyList();

foreach(Survey s in surveys)
{
            //this link bellow is working fine
            MessageBox.Show("Survey Id:"+s.SurveyId); 

            List<Collector> collectorList = s.Collectors;
            //this line bellow give a System.NullReferenceException in "collectorList"
            foreach (Collector c in collectorList)
            {
             //Other instructions

            }
}

PS:我尝试了PHP包装器版本,它运行正常。

1 个答案:

答案 0 :(得分:2)

包装器的GetSurveyList方法调用/ surveys endpoint(https://developer.surveymonkey.net/api/v3/#surveys)。不会填充页面,问题和收集器等集合。如果您想获得相关的收藏家,您需要进行另一次API调用。这将为您做到:

foreach (Survey s in surveys)
        {
            List<Collector> collectorList = sm.GetCollectorList(s.Id);
            foreach (Collector c in collectorList)
            {
                //Other instructions
            }
        }