0

I am trying to create a task and assigning it to me in ASANA using c#. Following is my JSON request that I am sending to ASANA

{"data":[{"assignee":"aaaa@bbb.com","name":"API Test","notes":"I am testing ASANA API","workspace":{"id":1234569789512,"name":"company.com"},"assignee_status":"inbox","due_on":""}]}

This is the response I get {"data":{"id":1234568,"created_at":"2014-10-24T20:41:02.839Z","modified_at":"2014-10-24T20:41:02.839Z","name":"","notes":"","completed":false,"assignee_status":"upcoming","completed_at":null,"due_on":null,"workspace":{"id":123456,"name":"company.com"},"num_hearts":0,"assignee":null,"parent":null,"hearts":[],"followers":[{"id":123456,"name":"MyFirstname MyLastname"}],"projects":[],"tags":[],"hearted":false}}

I don't see any tasks when I log on to ASANA. So I am not sure what it created where it created since there is no error but it does have an ID. But from the response it looks like it ignores name, notes and assingee_status that I am passing in the request. I thought [ and ] might be an issue as ASANA may not consider data as a top level element, so I removed it, matching the request as the response I am getting, but that caused a "Bad Request" error.

So I am not sure what I am doing wrong ?

Reading other post, i have checked the following, ContentType is application/json Web Request method is POST URL I am posting to is https://app.asana.com/api/1.0/workspaces/Workspace_ID/tasks

And I think my top level dictionary element is data. I am not good at JSON so this might be an issue of top level element, but I am not sure how to fix it.

Any suggestions or hint or guidance is greatly appreciated.

Thanks.

I removed the [ and ] and workspace: Here is the json request, But I get 400 Bad Request from the server {"data":{"assignee":"myemail@company.com","name":"API Test","notes":"Vivek is testing ASANA API","assignee_status":"inbox","due_on":""}}

1 Answers1

0

You are correct that the top-level data attribute is necessary, but the payload should not be in an array ([ and ]) - additionally, you can skip the workspace (since you specify it in the URL). Hope that helps!

agnoster
  • 3,744
  • 2
  • 21
  • 29
  • I removed [ and ] as well as workspace. I get a bad request from the server. Here is my json request {"data":{"assignee":"myemail@company.com","name":"API Test","notes":"Vivek is testing ASANA API","assignee_status":"inbox","due_on":""}} – Vivek Patel Oct 27 '14 at 20:49
  • What does the Bad Request error say? There's usually an error message or something to go along with the response. Try paring it down to the bare minimum - say, just notes and name - and see if it still works. It looks like either due_on or assignee might be presenting problems, though I'm not 100% sure. – agnoster Oct 28 '14 at 00:06
  • 1
    due_on was the issue. I removed it and ran it and I was able to create a task and I was able to see task in ASANA front End. Thanks Agnoster to pointing me to this. – Vivek Patel Oct 28 '14 at 20:05