谷歌调查-我如何设置一个假值为lastAnswerPositionPinned



我正在与Google.Apis.ConsumerSurveys合作。. net的NuGet包,版本1.15.0.564.

我发现,如果我POST到具有"lastanswerpositionpins":false的SurveyQuestion的调查资源,它被解释为API的真值。如果我使用"lastAnswerPositionPinned": null,它将被解释为假值。

下面是POST中Survey主体的一个例子:

{
  "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":空
对于第二个问题,第二个答案不固定(如期望的那样)。

所以我的问题是:它是由API要求,当一个可空的布尔属性被期望为false,它必须作为null而不是false发送吗?

是的,你现在需要在API中指定布尔属性为null。

EDIT:这不再是真的。该错误已被修复,将值指定为"false"将导致API中的"false"值。

空值也会被解释为false

相关内容

  • 没有找到相关文章

最新更新