Get tasks from a project returns incorrect and unpredictable custom field values.

I’m trying to read the values of a custom field for a task using https://app.asana.com/api/1.0/projects/{project_gid}/tasks.

Please note that the following snippets have been redacted and GIDs appear malformed. They are correctly formed in the actual calls.

This is what the call looks like:

curl --request GET --url 'https://app.asana.com/api/1.0/projects/1------------2/tasks?opt_fields=custom_fields'      --header 'accept: application/json'     \
 --header 'authorization: Bearer ey...dHKaSo' | jq

Most of the time, the response looks like this, incorrectly showing no people_value or display_value for the given custom field.

{
  "data": [
    ....,
    {
      "gid": "1-----------------1",
      "custom_fields": [
       {
          "gid": "1--------------------4",
          "enabled": true,
          "name": "Tester",
          "description": "",
          "created_by": {
            "gid": "1--------------------------7",
            "name": "S--------------n",
            "resource_type": "user"
          },
          "display_value": "",
          "resource_subtype": "people",
          "resource_type": "custom_field",
          "people_value": [],
          "is_formula_field": false,
          "is_value_read_only": false,
          "type": "people"
        }
      ]
    }
  ]
}

I’ve received the correct response once, in hundreds of attempts. Note that the people_value field is a non-empty array, and display_value is set accordingly. That looks like this:

{
  "data": [
    ...,
    {
      "gid": "1-----------------1",
      "custom_fields": [
       {
          "gid": "1--------------------4",
          "enabled": true,
          "name": "Tester",
          "description": "",
          "created_by": {
            "gid": "1--------------------------7",
            "name": "S--------------n",
            "resource_type": "user"
          },
          "display_value": "S--------------n, J---------------------m",
          "resource_subtype": "people",
          "resource_type": "custom_field",
          "people_value": [
            {
              "gid": "1--------------------------7",
              "name": "S--------------n",
              "resource_type": "user"
            },
            {
              "gid": "1-----------------2",
              "name": "J---------------------m",
              "resource_type": "user"
            }
          ],
          "is_formula_field": false,
          "is_value_read_only": false,
          "type": "people"
        }
      ]
    }
  ]
}

I’ve made no changes to the resources or my access levels to them while testing these requests.

Any ideas?

1 Like

Bump

The response where the people_value is an empty array and display_value is an empty string looks like the right response if that particular task does not have any people assigned to that custom field. If you take the task GID of one those tasks where the people_value is an empty array, and make an API call to get only that task, do you get a different result?

curl --request GET 
  --url 'https://app.asana.com/api/1.0/tasks/1234567890?opt_fields=custom_fields
  --header 'authorization: Bearer asdf...xyz'

I haven’t had a chance to test your theory, but thank you for the reply. I’ll give it a whirl when I get a chance to get back to that particular piece of code.

Might be worth noting, the original requests were all for the same data. I was making repeated requests for the same set of tasks from the same project and seeing different results.