I am having trouble creating an asana task with external data. I can create a task fine, but i can't figure out what the cocktail is to be able to use the "external" data that is mentioned in the documentation.
$.ajax({
url : global.task.url,
type: "post",
data: {
assignee: "my-email@hidden.com",
name: "Test task",
notes: "this is a note",
projects: 123123123123,
workspace: global.workspace,
external: {
"id": "test",
"data": "12345099"
}
},
beforeSend: function (xhr) {
xhr.setRequestHeader("Authorization", "Bearer " + "MY-TOKEN");
}
})
the above code results in a 500 bad request.
I have also tried sending external stringified, which results in the error "No matching route for request".
The code above works perfectly if i remove the "external" from data.
i will be the first to say i do not typically call APIs so i feel like i must be doing something silly. any help appreciated!
UPDATE:
i was able to create a task by passing in external as:
'external.id' = "test",
'external.data' = "123123123"
however, i do not see the external data i generated, so there is still something going on.
UPDATE (2):
if i run the code below, i will get a 500 server error. if i comment out the "external" piece in the data, the tasks adds correctly.
$.ajax({
url : "https://app.asana.com/api/1.0/tasks",
contentType: "application/json",
type: "post",
beforeSend: function (xhr){
xhr.setRequestHeader("Authorization", "Bearer " + settings.token);
},
data: JSON.stringify({
data: {
assignee: "my-email@hidden.com",
name: "Test task",
notes: "this is a note",
projects: [5555555555555], //not the real one i am passing in
external: {
id: "testID",
data: "some sweet data"
},
workspace: 555555555555 //not what i am really passing in
}
})
})
Could it be you already created a record with the id test
? The IDs are unique - they have to be, or you couldn't use it for access. Try a random ID or something? You can always GET /tasks/external:test
and see if there's a task there.