Unable to create Task using API in Asana


#1

Hello,

I am trying to create a task under a workspace in Asana.

Payload i have prepared to push to Asana:
{“data”:{“workspace”:{“resource_type”:“workspace”,“name”:“cm-focus.com”,“id”:967840855208084,“gid”:“967840855208084”},“notes”:“Creative Update notes”,“name”:“Creative Updates”,“assignee”:[{“resource_type”:“user”,“name”:“Pradip”,“id”:967839896278404,“gid”:“967839896278404”}]}}

But i am getting a error message as response :
{“errors”:[{“message”:“workspace: Not a valid GID type: “object”.”,“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”}]}

I am not able to understand the reason as all the details available in the payload is correct.

Any kind of help on this is highly appreciated.


#2

Hi @Soumen_Jana,

Don’t specify the whole object for the workspace and for the user; for each of those, just provide the ID.

I haven’t tested this syntax specifically but basically you want something like this:

{“data”:{“workspace”:“967840855208084”,“notes”:“Creative Update notes”,“name”:“Creative Updates”,“assignee”:“967839896278404”}}


#3

Thanks Phil. That worked like magic however if i add another parameter to the request to associated with project , failing.

Sample Request Body : {“data”:{“workspace”:“967840855208084”,“projects”:[“967839896278404”],“notes”:“Creative Update notes”,“name”:“Creative Updates”,“assignee”:“967839896278404”}}

Response : {“errors”:[{“message”:“projects: [0]: Not the correct type”,“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”}]}

It’s mentioned in the API documentation that we need to send projects in form of array.

Thanks.


#4

Please don’t mind my last comment.


#5

Hi @Soumen_Jana,

If you have an updated version of your last sample which is working now, it would be great if you could post it - just so others who come upon this post later can see the working sample. Thanks!