Write, Bureaucrats, Administrators
4,332
edits
mNo edit summary |
mNo edit summary |
||
Line 350: | Line 350: | ||
<source lang="javascript"> | <source lang="javascript"> | ||
// Create a JSON command for Todoist task creation using the format described in [https://develop.todoist.com/#add-an-item]. | |||
// This command should include a unique identifier created using the guid() global function. | |||
var commands='[{"uuid":"' + guid() + '","temp_id":"' + guid() + | var commands='[{"uuid":"' + guid() + '","temp_id":"' + guid() + | ||
'","type":"item_add","args":{"content":"' + entry().field("Task") + '"}}]' | '","type":"item_add","args":{"content":"' + entry().field("Task") + '"}}]' | ||
// Execute the HTTP request. An attribute called '''token''' is used for authorization in Todoist. It is available in the Todoist Account setting. | |||
// Since the text of the task can include symbols not allowed in a URL request, use the standard function encodeURIComponent() to filter them out. | |||
result = http().get("https://todoist.com/API/v7/sync?token=15281e8e4d499dаff817af0b14112eac3176f9dc&commands=" + | result = http().get("https://todoist.com/API/v7/sync?token=15281e8e4d499dаff817af0b14112eac3176f9dc&commands=" + | ||
encodeURIComponent(commands)) | encodeURIComponent(commands)) | ||
// Show the user a message indicating successful creation of the task. | |||
if (result.code == 200) message('Task has been successfully created") | if (result.code == 200) message('Task has been successfully created") | ||
</source> | </source> |