Search code examples
c#.netasana

When created asana task using json and .net - asana api does not save its name, assinge or project information


Im trying to add new task to asana using asana api. Im using Json.net and C#, the json Im sending to server (https://app.asana.com/api/1.0/workspaces/555/tasks)looks like this:

{"name":"aaaaaaaaaaaaa","assignee":111,"workspace":222,"followers":[333],"project":[444]}

Then the response from server is:

*{"data":{"id":1341474003806,"created_at":"2012-07-26T22:50:40.603Z","modified_at":"2012-07-26T22:50:40.603Z","name":"","notes":"","completed":false,"assignee_status":"later","completed_at":null,"due_on":null,"assignee":null,"workspace":{"id":555,"name":"workspacename"},"projects":[],"tags":[],"followers":[{"id":333,"name":"username"}]}}*

So looks asana doesn't save the task name, followers, assignee and project information that I'm sending to server. Also when I'm trying to update the task manually using following Uri (https://app.asana.com/api/1.0/tasks/1341474003806) with following json

{"name":"aaaaaaaaaaaaa"}

I get WebException with message "The remote server returned an error: (404) Not Found.". But I can still paste this address into web browser and see task details:
*{"data":{"id":1341474003806,"assignee":null,"projects":[],"tags":[],"created_at":"2012-07-26T22:50:40.603Z","modified_at":"2012-07-26T22:50:40.603Z","name":"","notes":"","completed":false,"assignee_status":"later","due_on":null,"workspace":{"id":222,"name":"Work development"},"followers":[{"id":333,"name":"username"}],"completed_at":null}}*
Also this task in not visible to me using web browser.

Am I doing something wrong? Maybe Im missing something in json? Could someone provide an example of how to create a task attached to workspace/project using .net. Or provide a dump o json that successfully creates a task. Or just point me a solution.
If necessary I can provide the source code.


Solution

  • (I work at Asana).

    The reason your specific fields are not being accepted on task creation is because you need to put them inside a data element in the top-level dictionary you are sending, the same way it appears in the response. Since all your fields appear outside that element, they are being ignored.

    The reason you are getting "not found" for your update request is you are probably using a POST (create) to that URL when you should be using a PUT (update). There is no API endpoint that accepts a POST to a specific task ID.