Search tasks in a workspace via node-asana

Is there any way to use de node-asana api to find tasks in a workspace with filters like custom fields?

I’m looking for this feature in the node-asana api:

And I’ve looked into the documentation and couldn’t find any answers.


client.tasks.findAll({workspace:workspaceId}).then(res => console.log(res))

thought this should work… but currently getting invalid request…

The invalid request error usually provides a detailed explanation, doesn’t it?

It does not, with the said example.
Note that I can make requests to other endpoints using this workspaceId and token.

That is weird, I double checked with the doc and source, and that should work. Did you inspect the request that is going out as a result?

Hi! I think you get the compact record of the task. Not sure actually if you can do that on the worskpace and get all tasks. I believe you should use the project id when using that request.

client.tasks.findAll(, {params: params}).then(res => console.log(res))
And it he params you should enter opt_expand: ‘custom_fields,notes,assignee’ <- and so on to list the key values you want from the task. Because the compact response only contains text, name, and gid.

But if you really want to search the api and not use your own filters and get more lightweight reponse i would create my own function and use the search api.

I did a quick code example if you want to create your own function using requestjs. You could use needle or something instead. Its a bit dirty here but should work if you just replace the values. =)

const request = require(‘request’);

// Your token
const token = ‘abcd1234’;

// The function with the searsh string
const findNewTask = (text, projectId, customFieldId) => {
const searchString =${projectId}&custom_fields.${customFieldId}.value=${encodeURI( text )}&opt_fields=name,tags,completed,assignee,notes,custom_fields;

return new Promise((resolve, reject) => {
method: ‘GET’,
url: ${searchString},
headers: { Authorization: Bearer ${token} },
json: true,
function(error, res, body) {
if (!error) {
} else {

// Run the function
findNewTask(‘text to search’, ‘ProjectGIDs’, ‘customFieldId’).then(response => console.log(response));

Yeah i get that, but the question was if there was any way using Asana’s NodeJS api, I’ve mentioned that endpoint’s documentation in my question, and that is my current setting. I was really just hoping for a Yes/No answer, since there is no documentation for it.

I guess the answer is No. Despite the helpful answers with questions.

Ok. No!

1 Like

Hi @dfc, I believe you’re looking for the client.tasks.searchInWorkspace() method, which hits the /workspaces/{workspace_gid}/tasks/search endpoint you linked to in the docs.