2

I am trying to create an Asana task using curl on the Debian command line. I am assigning the task to a specific project and a specific section within that project. My curl command creates a task until I add the "memberships" parameter. Here is what that parameter looks like.

-d "memberships=[{project:{id:96927952190628},section:{id:96927952190688}}]"

Here is the full command (with some information removed for privacy):

curl -H 'Authorization: Bearer <id>' https://app.asana.com/api/1.0/tasks -d "assignee=me" -d "name=New Task" -d "completed=false" -d "workspace=923066726484" -d "memberships=[{project:{id:96927952190628},section:{id:96927952190688}}]"

This appears to be match the requirements based on the Asana API described here: https://asana.com/developers/api-reference/tasks#create (see the example in the definition for the 'memberships' field).

When I execute this command, Asana returns the following json.

{"errors":[{"message":"memberships: [0]: project: Missing required field","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"}]}

So, what am I doing wrong?

Thanks!

Will Reade
  • 23
  • 3
  • I am experiencing a similar issue with specifying memberships - the JSON appears to be valid, but I'm getting this response from Asana: `memberships: [0]: project: Not a valid ID type: object` – Blake Beaupain Apr 22 '16 at 20:29

1 Answers1

2

It looks to me like you need to pass project: 96927952190628 instead of project: {id: 96927952190628} (and similarly for section)

Note this only works on creation.

Example (replace the numbers and token):

curl -H "Authorization: Bearer 0/YOURPAT" -X POST "https://app.asana.com/api/1.0/tasks" -H "content-type: application/json" -d "{\"data\": { \"workspace\": 12, \"name\": \"test\", \"memberships\": [{ \"project\": 123, \"section\": 1234 }] }}"

Mark
  • 176
  • 4