Hi,
I am currently getting all tasks related to a given project, but, even though the documentation says I should receive the following elements when asking for Projects in opt_fields :
“projects”: [
{
“gid”: “12345”,
“resource_type”: “project”,
“name”: “Stuff to buy”
}
],
…all I get is gid and resource_type in the elements received from the API call…
Can anybody help me on this, since d like to avoid calling the API another time for projet data.
Thanks a lot !
ug_josh
September 8, 2023, 12:21pm
2
Hi @Julien_Levy
what does your request look like?
Checkout the Input/Output Options and make sure you include “name” in your api call
You can also test here: Get a project
Hi,
Thanks for your quick answer !
my request is as follows :
let response = UrlFetchApp.fetch(‘https://app.asana.com/api/1.0/tasks?project=123456&opt_fields=name,due_on,permalink_url,projects,custom_fields ’
Shall I be more specific ?
Hi,
My first suggestion to know which opt_fields are available, is NOT to look at the documentation
Instead, query one single task (/tasks/xxx), look at all the fields in the response, and use them when you query multiple tasks.
I think “projects” opt_field should work, but you can use memberships.project (without s) instead.
Sections are also in memberships.
You can add sub-fields, like
memberships.project.name
So, your query can look like this:
GET /projects/123456/tasks?opt_fields=name,due_on,permalink_url,memberships.project,custom_fields
(using /projects/12345/tasks is the same as /tasks?project=xxx)
Thanks a lot !!
I can now get a project name with that kind of request :
GET /projects/123456/tasks?opt_fields=name,due_on,permalink_url,projects.name,custom_fields
The problem is that wuth such a request I only get one projet for a given task, whereas I know that some are associated to several projects…
Any idea how to solve that ?
@Julien_Levy ,
Use this option that @Frederic_Malenfant mentioned:
opt_fields=memberships.project.name
(and of course you an add other fields that you might want as well)
1 Like