Stories API data contain wrong set of fields

Hello. I’m trying to build my app with using asana api, but unfortunately I ran into problems with information in api documentation and actual data from server. In Stories documentation I found that fields target and created_by contain field name, in examples above text I could see

    {
      "text": "added to Things To Buy",
      "created_at": "2011-12-21T23:23:01.259Z",
      "type": "system",
      "id": 2001,
      "created_by": {
        "id": 5678,
        "name": "Greg Sanchez"
      }
    }

but in fact from server came only id, gid and resource_type

  {
     "id": 857426476495644,
     "gid": "857426476495644",
     "created_by": {
       "id": 837375362838,
       "gid": "837375362838",
       "resource_type": "user"
     },
     "target": {
       "id": 857426475869664,
       "gid": "857426475869664",
       "resource_type": "task"
     }
   }

You need to put in the opt_field parameter the exact fields you want returned.

1 Like

I did it. I need 3 fields, target , text , created_by and I pass them into parameters in my request url https://app.asana.com/api/1.0/tasks/857382641331504/stories?opt_fields=target%2Ctext%2Ccreated_by but how I need to specified fields inside fields?

You can use this: parentField.field

2 Likes

Thanks, its works as well

2 Likes