Assign a task to a project shown


#1
Hello everbody, I have a question. I want to doing assign a task to a project shown.As picture my form =


(document).ready(function () { var settings = { "url": "https://app.asana.com/api/1.0/projects?opt_fields=created_at,modified_at,owner,due_date,current_status,public,name,notes,archived,workspace,color,members,followers", "method": "GET", "timeout": 0, "headers": { "Authorization": ".!.!.!.!.!.!.!.!.!" }, }; .ajax(settings).done(function (response) {
for (var i = 0; i < response.data.length; i++) {
("#selectproject"). append(("" + "Proje ID = " + response.data[i].id + " " + " " + "Proje Adı = " + response.data[i].name + “”));
}
var selectElem = document.getElementById(‘selectproject’);
selectElem.addEventListener(‘change’, function () {
form_kontrol();
var index = selectElem.selectedIndex;
console.log(index);
swal(“Listeleme Başarılı!”);
return 0;

    })
});

//});
//(document).ready(function () { ("#formgonder").click(function () {
("#tasklistname").val ( .trim(("#tasklistname").val()) ) ("#tasklistdesc").val
(
.trim(("#tasklistdesc").val())
)
var tasklistisim = ("#tasklistname").val(); var tasklistaciklama = ("#tasklistdesc").val();
if (tasklistisim == ‘’ || tasklistaciklama == ‘’) {
swal(“Oops”, “Lütfen Boş Kutuları Doldurunuz!”, “error”)
} else {
swal(“Tebrikler”, “((” + tasklistisim + “))” + “Adlı Kaydınız Başarılı!”, “success”)
var settings = {
“url”: “https://app.asana.com/api/1.0/tasks?projects=.!.!.!.!.!.!.!.!.!&workspace=.!.!.!.!.!.!.!.!.!”,
“method”: “POST”,
“timeout”: 0,
“headers”: {
“Authorization”: “Bearer .!.!.!.!.!.!.!.!.!”
},
“data”: {
“name”: tasklistisim,
“notes”: tasklistaciklama
}
};
$.ajax(settings).done(function (response) {
console.log(response);
location.reload();
});
}
});
});


#2

Can you try to format the code correctly please? That is pretty hard to read :sweat_smile:
You should use triple backquotes before and after the code, alone on their line.
Thanks :+1:


#3

Hello, it’s so late :slight_smile: I solved the problem
Thank You


#4

Can you share the solution?


#5


Firstly ,you can see my form design .Also You can see code at link .I hope , ı can help for you
https://drive.google.com/file/d/1IC2nIcEGV3wlX7tBqdqiBCC6S7Ofb8V1/view?usp=sharing


#6

In your call to create the task, try this:

  1. Remove the “projects” and “workspace” parameters from the URL string.
  2. Instead, put “projects” as a data element along with “name” and “notes” and pass the selected project Id there. This element needs to be an array, even if there’s only one project Id as there will be in your case.

According to the API docs, if you supply a project you don’t need to supply the workspace.