Unable to create a task in a project using node.js lib.

Hi there,

Using the lib, there’s no parameter project, hence I can’t specify where the task goes. workspace parameter works, but that’s not helping my problem.

Any ideas what’s happening here? I’m reverting back to plain axios.post requests for now to get it done.

module @types/asana

interface Tasks extends Resource {
             * * Creating a new task is as easy as POSTing to the `/tasks` endpoint
             * * with a data block containing the fields you'd like to set on the task.
             * * Any unspecified fields will take on default values.
             * *
             * * Every task is required to be created in a specific workspace, and this
             * * workspace cannot be changed once set. The workspace need not be set
             * * explicitly if you specify a `project` or a `parent` task instead.
             *   * @param {Object} data Data for the request
             *   * @param {Number} [data.workspace] The workspace to create a task in.
             *   * @param {Object} [dispatchOptions] Options, if any, to pass the dispatcher for the request
             *   * @return {Promise} The response from the API
             * @param data
             * @param dispatchOptions?
             * @return
            create(data: Tasks.CreateParams & { workspace: string }, dispatchOptions?: any): Promise<Tasks.Type>;

 const task = await asana.tasks
        name: `${f.ranch.displayName} ${f.block.name}`,
        project: "1201766605631196",
        notes: ``,
      .then((e) => console.log(e, "inserted"))
      .catch((e) => console.log(e.value));

>    errors: [
>      {
>        message: 'You should specify one of workspace, parent, projects',
>        help: 'For more information on API status codes and how to handle them, read the docs on errors: https://asana.com/developers/documentation/getting-started/errors'
>      }  


If you look at the payload on the right side of the documentation you’ll see that the attribute is projects and is a string array :slight_smile:

1 Like


He’s talking about the nodejs library and not the REST API, which won’t take a project parameter. So what’s the workaround in that case ?

In the nodeJS library, the attribute on a task is projects (plural) and it takes an array of projects ids.