I'm trying to create a new task using the node.js asana library and I'm getting weird 500 errors:
500 error
{
message:"Server Error"
phrase: "29 bizarre cobras wait hourly"
}
create code
var task = {
name: card.name,
notes: card.desc,
memberships: [ { project: { id: someId, name: 'Discovery' }, section: section }],
parent:null,
workspace: workspaceId
};
client.tasks.create(task).then((results) => {
console.log(JSON.stringify(task));
}).catch((err) => {
console.error(err);
});
As mentioned in the error code documentation, "In the event of a server error the response body will contain an error phrase. These phrases are automatically generated using the node-asana-pharse library and can be used by Asana support to quickly look up the incident that caused the server error."
In this case the error is generated due to a poorly formed memberships
parameter in the POST payload. Object references as parameters in the API only include the ID for the object instead of an actual object.
project: 123
project: { id: 123, name: 'Discovery' }
Therefore, the memberships parameter should be
memberships: [ { project: 123, section: "A Section" }]