1

我正在使用适用于 .Net 的 Google.Apis.ConsumerSurveys.v2 NuGet 包,版本 1.15.0.564。

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

以下是 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 是否要求当一个可为空的布尔属性为 false 时,是否必须将其作为 null 而不是 false 发送?

4

1 回答 1

1

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

编辑:这不再是真的。该错误已得到修复,指定值"false""false"在 API 中生成一个值。

Null 值将被解释为 false。

于 2016-08-12T18:55:44.350 回答