-
Does this API allow notifications when Todoist items are added, changed or deleted? |
Beta Was this translation helpful? Give feedback.
Answered by
olsh
Nov 3, 2024
Replies: 1 comment
-
There is no such feature, but you can achieve something similar using the var client = new TodoistClient(Util.GetPassword("todoist.api.key"));
// Set the initial sync token to "*" to fetch all items in the first request.
var syncToken = "*";
// Perform the initial synchronization to get all items and store the new sync token.
var initialResponse = await client.GetResourcesAsync(syncToken, ResourceType.Items);
syncToken = initialResponse.SyncToken;
while (true)
{
await Task.Delay(TimeSpan.FromSeconds(10));
// Fetch incremental updates for items using the latest sync token.
var incrementalResponse = await client.GetResourcesAsync(syncToken, ResourceType.Items);
// Iterate over each updated item received in the incremental response.
foreach (var item in incrementalResponse.Items)
{
Console.WriteLine($"Item {item.Id} was updated");
}
// Update the sync token for the next iteration to ensure subsequent updates are fetched.
syncToken = incrementalResponse.SyncToken;
} |
Beta Was this translation helpful? Give feedback.
0 replies
Answer selected by
olsh
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
There is no such feature, but you can achieve something similar using the
GetResourcesAsync
method. Here is a simple implementation: