我正在使用.Net版本1.15.0.564的Google.Apis.ConsumerSurveys.v2 NuGet包。
我发现如果我使用具有“lastAnswerPositionPinned”的SurveyQuestion POST到Surveys资源:false,它将被API解释为真值。如果我使用“lastAnswerPositionPinned”:null,则将其解释为false值。
以下是POST中调查主体的示例:
{
"audience": {
"ages": null,
"country": "US",
"countrySubdivision": null,
"gender": null,
"languages": [
"en-US"
],
"mobileAppPanelId": null,
"populationSource": "general",
"ETag": null
},
"cost": null,
"customerData": null,
"description": "",
"owners": null,
"questions": [
{
"answerOrder": null,
"answers": null,
"hasOther": null,
"highValueLabel": "Good",
"images": null,
"lastAnswerPositionPinned": null,
"lowValueLabel": "Bad",
"mustPickSuggestion": null,
"numStars": "ten",
"openTextPlaceholder": null,
"openTextSuggestions": null,
"question": "Rate me",
"sentimentText": null,
"singleLineResponse": null,
"thresholdAnswers": null,
"type": "ratingScale",
"unitOfMeasurementLabel": null,
"videoId": null,
"ETag": null
},
{
"answerOrder": "randomize",
"answers": [
"One",
"Two"
],
"hasOther": null,
"highValueLabel": null,
"images": [
{
"altText": "Me",
"data": "iVBORw0KGgoAAAANSUhEUgAA(truncated...)",
"url": null,
"ETag": null
}
],
"lastAnswerPositionPinned": false,
"lowValueLabel": null,
"mustPickSuggestion": null,
"numStars": null,
"openTextPlaceholder": null,
"openTextSuggestions": null,
"question": "What do you think?",
"sentimentText": null,
"singleLineResponse": null,
"thresholdAnswers": null,
"type": "singleAnswerWithImage",
"unitOfMeasurementLabel": null,
"videoId": null,
"ETag": null
}
],
"state": null,
"surveyUrlId": null,
"title": "Stars",
"wantedResponseCount": 100,
"ETag": null
}
请注意,有两个问题。在第二个中,lastAnswerPositionPinned属性被发送为false。
当我使用GCS UI查看创建的调查时,我发现第二个问题中的第二个答案是固定的。当我从GCS API检索调查时,我得到:
{
"audience": {
"ages": null,
"country": "US",
"countrySubdivision": null,
"gender": null,
"languages": [
"en-US"
],
"mobileAppPanelId": null,
"populationSource": null,
"ETag": null
},
"cost": {
"costPerResponseNanos": 1000000000,
"currencyCode": "USD",
"maxCostPerResponseNanos": null,
"nanos": 100000000000,
"ETag": null
},
"customerData": null,
"description": null,
"owners": [
"xxx@gmail.com",
"xxx.iam.gserviceaccount.com"
],
"questions": [
{
"answerOrder": "sorted",
"answers": null,
"hasOther": null,
"highValueLabel": "Good",
"images": null,
"lastAnswerPositionPinned": null,
"lowValueLabel": "Bad",
"mustPickSuggestion": null,
"numStars": "ten",
"openTextPlaceholder": null,
"openTextSuggestions": null,
"question": "Rate me",
"sentimentText": null,
"singleLineResponse": null,
"thresholdAnswers": null,
"type": "ratingScale",
"unitOfMeasurementLabel": null,
"videoId": null,
"ETag": null
},
{
"answerOrder": "randomize",
"answers": [
"One",
"Two"
],
"hasOther": null,
"highValueLabel": null,
"images": [
{
"altText": "Me",
"data": null,
"url": "//lh3.googleusercontent.com/pCNzD9iFpOJlv0Hj7rM9XcwYxgggM9kEVj3xqgYeIRZLDYCF4eaczNt2MZNc9uhodrcqXhO1DVE93SiFZYPQ=w187-h250",
"ETag": null
}
],
"lastAnswerPositionPinned": true,
"lowValueLabel": null,
"mustPickSuggestion": null,
"numStars": null,
"openTextPlaceholder": null,
"openTextSuggestions": null,
"question": "What do you think?",
"sentimentText": null,
"singleLineResponse": null,
"thresholdAnswers": null,
"type": "singleAnswerWithImage",
"unitOfMeasurementLabel": null,
"videoId": null,
"ETag": null
}
],
"state": "editable",
"surveyUrlId": null,
"title": "Stars",
"wantedResponseCount": 100,
"ETag": "\"ZiP0PqJvpbOMVu8_oCFcU_sZBNY/t6y6f1fN1fnFYzyKHjcNyj4eexQ\""
}
请注意,API会报告第二个问题的lastAnswerPositionPinned属性为真。
我发现如果我使用
重复这个测试
“lastAnswerPositionPinned”:null
对于第二个问题,第二个答案没有固定(根据需要)。
所以我的问题是: API是否需要当可以为空的布尔属性为假时,是否必须将其作为null而不是false发送?
答案 0 :(得分:1)
是的,您现在需要在API中将布尔属性指定为null。
编辑:这已不再适用。该错误已得到修复,将值指定为"false"
将在API中生成"false"
值。
空值也被解释为false。