Ethan, see if this helps get you there. I wrote a script kind of like this before, but that took a dedicated folder
(list) variable. Here’s a modification that parses the list name from the draft as you described — but I don’t have my API key handy to try it out, so this looks right but it’s untested.
let api = "YOUR_API_KEY";
let firstLine = draft.processTemplate("[[line|1]]"),
splitLine = firstLine.split("@"),
current = splitLine[0].trim(),
folder = splitLine[1] ? splitLine[1].trim() : "";
if (!folder) {
alert("Folder not provided in the draft");
context.fail();
} else {
let req = new HTTP(),
result = req.request({
encoding: "json",
method: "POST",
data: {
title: current,
},
headers: {
"Content-type": "application/json; charset=UTF-8",
"Authorization": `Bearer ${api}`,
},
url: `https://graph.microsoft.com/v1.0/me/todo/lists/${folder}/tasks`,
});
if (result.success) {
alert(result.responseText);
} else {
alert(`Error: ${result.statusCode} - ${result.error}`);
}
}
Good luck!