我想要使用SurveyMonkey API來獲取問題&在.NET應用程序中的答案,並且我正在起訴.Net包裝。 我可以獲得有關調查的一般信息,例如(surveyId,問題數量等),但是當我嘗試獲取收集器或問題或響應或任何其他對象時,出現錯誤,指出這些對象爲空。 這裏是一塊的什麼,我試圖做System.NullReferenceException與SurveyMonkey .Net包裝
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包裝版本,它是工作的罰款。
我假設s.Collectors提取該調查的收集器,但它做了什麼確切的API調用?它回來了什麼?它甚至打電話,或者你必須首先填充收藏家,然後你可以調用's.Collectors'?我需要看到.NET包裝程序代碼來幫助調試,現在它看起來像s.Collectors是空的。 –
是s.Collectors肯定爲null。我認爲包裝的代碼源可在[鏈接](https://github.com/bcemmett/SurveyMonkeyApi) – GENE
可能重複[什麼是NullReferenceException,我該如何解決它?](http:// stackoverflow.com/questions/4660142/what-is-a-nullreferenceexception-and-how-do-i-fix-it) – Enigmativity