Color property is not shown when using GET all tags/projects API.

StackOverflow https://stackoverflow.com/questions/18473851

  •  26-06-2022
  •  | 
  •  

Вопрос

when we use this API https://app.asana.com/api/1.0/tags, the id and name of the tag is alone exposed... we get this response without colour property

{"data":[{"id":745415432,"name":"niceTag"},{"id":74273131186,"name":"halfBoil"},          {"id":745540236,"name":"DummyTag"}]}

To get the colour property of the tags, we need to individually make a GET request to https://app.asana.com/api/1.0/projects/project-id.

{"data":{"id":123456789,"created_at":"2013-08-15T01:17:32.791Z","modified_at":"2013-08-27T19:14:00.570Z","name":"newPro","notes":"","archived":false,"workspace":{"id":6687953,"name":"t"},"color":"light-yellow","followers":[{"id":987654321,"name":"xxxxx"}]}}

I might be unnecessarily using the server resource for getting colour properties of individual tags. Is there any other way to get the colours?

Это было полезно?

Решение

In most requests for a set of resources, we send what's called the "compact" form - for tags and projects, this includes only the ID and name. However, you can use the opt_fields parameter to request specific fields. For example, if you wanted to get all projects with name and color (ID is always sent), you could use: https://app.asana.com/api/1.0/projects\?opt_fields\=name,color

This works for any fields you need in a collection. For more information on opt_fields and other tricks (like using opt_expand to expand embedded resources) see the documentation on input/output options.

Лицензировано под: CC-BY-SA с атрибуция
Не связан с StackOverflow
scroll top