Search code examples
node.jsapiasana

Asana API POST to Tasks leads to Server Error


I'm using node.js and the api key for auth. All my get actions work, and I've been able to post a new project, but new tasks always return 'server error'. Here's the object I'm sending to the /tasks endpoint:

data: {
 name: 'Figure this out',
 notes: '',
 assignee: null,
 completed: false,
 assignee_status: 'later',
 completed_at: null,
 due_on: null,
 tags: [],
 parent: null,
 followers: [ { id: 5622986387066 }, { id: 5622895459066 } ],
 projects: [ 6156399090409 ],
 workspace: 1707039411020 
}

Any ideas? I've tried passing those ID values a variety of ways, and I've tried creating a more simple task, always fails with a 'server error' response.


Solution

  • Seems like it's the "parent": null that's causing the unhelpful Server Error, which definitely seems like a bug on our side - I've filed it and will hopefully get time to look into it soon. Trim that out, and it gives you actual error messages.

    Just to save you some time: you can't set completed_at or tags, and followers should be just an array of integers ("followers": [ 5622986387066, 5622895459066 ]).

    You can set completed: [true/false], and the completed_at will be set to the time at which it was marked complete. Not being able to attach tags to a task is a known issue, and one we're hoping to rectify.

    Additionally, it's just a little annoying that the format of a response doesn't map 1-1 to the format for posting/updating. We're hoping to do a pass on the overall design of the API to unify those parts a bit more.