Create a task via API

Hello,

Im attempting to use Postman to create a task and am getting the following error: " “message”: “You should specify one of workspace, project, tag, section, user_task_list”,"

Here is a copy of the JSON I am Posting with my workspace ID removed, any help would be lovely!

{
“data” : {
“workspace” : “XXXXX”,
“assignee” : “XXXXX”,
“projects” : ,
“name” : “Test API Task”,
“start_on” : “2022-04-01”,
“due_at” : “2202-04-02T10:30:00Z”
}
}

Hi @anon16937584 and welcome to the forum!

I’m pretty sure you’ll get the error if the workspace ID is not valid; are you 100% sure you’re specifying a valid workspace? (You can do a Get Workspace in Postman to verify it.)

1 Like

100% positive im using the correct workspace ID. I confirmed it with the get workspace as well as getting an already created task and validating the workspace ID.

I would do a couple of things.

First, remove the empty projects array; it doesn’t serve any purpose and might be the cause of the problem.

I’d also add "resource_subtype": "default_task" - I’m almost sure it’s not required but it never hurts to explicitly specify what type of task you’re creating.

See if those help.

(BTW there’s no need to include the Workspace ID but also no real need to redact it; without someone having your credentials or a valid authentication token for your Asana account, a Workspace ID is useless to anyone else.)

Same results… This is my payload:
{
“data” : {
“name” : “Test API Task”,
“workspace” : “1200187295690951”,
“assignee” : “1200370755598100”,
“start_on” : “2022-04-10”,
“due_at” : “2202-04-21T10:30:00Z”,
“resource_subtype”: “default_task”
}
}

@anon16937584 - Syntax! It looks like the way the JSON is nested needs to be specific. Try this payload…

{
  "data": {
    "approval_status": "pending",
    "assignee": "1200370755598100",
    "assignee_status": "upcoming",
    "completed": false,
    "name": "Buy catnip",
    "notes": "Mittens really likes the stuff from Humboldt.",
    "projects": [
      "12345"
    ],
    "workspace": "12345"
  }
}

I am having the same issue. My JSON is indented and I also tried it without any spaces, but no luck.

Indentation does not matter in the JSON one supplies to the Asana API.

@Stan1 if you want to post exactly what you’re sending, we might be able to spot some issue(s).

1 Like

I was able to get it working in postman with these settings

That being said, I am still having issues with new lines, so if there is a way to use RAW JSON I’d prefer it, but I could not get it working