How do I set a false value for lastAnswerPositionPinned?

78 views Asked by At

I am working with the Google.Apis.ConsumerSurveys.v2 NuGet package for .Net, version 1.15.0.564.

I find that if I POST to the Surveys resource with a SurveyQuestion having "lastAnswerPositionPinned": false, it is interpreted as a true value by the API. If I use "lastAnswerPositionPinned": null, it is interpreted as a false value.

Here is an example of the Survey body in the 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
}

Note that there are two questions. In the second the lastAnswerPositionPinned property is sent as false.

When I look at the created survey using the GCS UI, I find that the second answer in the second question is pinned. When I retrieve the Survey from the GCS API I get:

  {
    "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": [
      "[email protected]",
      "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\""
  }

Note that the API reports the lastAnswerPositionPinned property for the second question to be true.

I find that if I repeat this test using
"lastAnswerPositionPinned": null
for the second question, the second answer is not pinned (as desired).

So my question is this: Is it required by the API that when a nullable boolean property is desired to be false, must it be sent as null instead of false?

1

There are 1 answers

1
Maia Werbos On

Yes, you need to specify boolean properties as null in the API for now.

EDIT: This is no longer true. The bug has been fixed, and specifying the values as "false" will result in a "false" value in the API.

Null values will also be interpreted as false.