microsoftgraph / msgraph-sdk-dotnet

Microsoft Graph Client Library for .NET!
https://graph.microsoft.com
Other
693 stars 246 forks source link

Patching a TodoTask which has a Recurrence value fails #2677

Open aaronsmithuk opened 3 days ago

aaronsmithuk commented 3 days ago

Describe the bug

I am trying to patch an existing TodoTask that has a recurrence value. It loads fine, but when I go to patch it (even with no changes), it results in: Invalid JSON, Error converting value "2025-09-23" to type 'Microsoft.OData.Edm.Date'. Path 'recurrence.range.endDate', line 1, position 46.

Expected behavior

It should patch the TodoTask without error and set the Recurrence changes.

How to reproduce

TodoTask tdTemp = new();
tdTemp.Recurrence = new()
    {
        Range = new()
        {
            Type = RecurrenceRangeType.EndDate,
            StartDate = new(DateTime.Now),
            EndDate = new(DateTime.Now.AddYears(1))
        }
    };
var result = await GraphClient.Users[MSGraphId.ToString()].Todo.Lists[list.Id].Tasks[task.Id].PatchAsync(tdTemp);

SDK Version

5.58.0

Latest version known to work for scenario above?

No response

Known Workarounds

No response

Debug output

Click to expand log ``` ```

Configuration

Windows 11, x64.

Other information

Someone else reported it here: https://learn.microsoft.com/en-gb/answers/questions/806339/unable-to-patch-a-todo-task-with-a-recurrence-patt

andrueastman commented 3 days ago

Thanks for raising this @aaronsmithuk

Any chance you can confirm if you can perform a successful update using the graph Explorer?

Taking a look at the issue at the link below, it may seem that the API may not support this. But it would be great to get confirmation on this.

https://learn.microsoft.com/en-us/answers/questions/806339/unable-to-patch-a-todo-task-with-a-recurrence-patt https://github.com/microsoftgraph/microsoft-graph-toolkit/issues/3182

aaronsmithuk commented 3 days ago

Tried it with Graph Explorer, looks like it isn't supported.

PATCH: https://graph.microsoft.com/v1.0/me/todo/lists/AQMkAGU0NjIxNzVkLTBlNmItNDA2ZS1iMjhmLTI1OWE5NDZhMTEAYmYALgAAA_cL2sajUMNGojd_LMDC69oBADS8myQQQ2tPjwencXfyCmEAAAIBEgAAAA==/tasks/AAMkAGU0NjIxNzVkLTBlNmItNDA2ZS1iMjhmLTI1OWE5NDZhMTFiZgBGAAAAAADnC9rGo1DDRqI3fizAwuvaBwA0vJskEENrT48Hp3F38gphAAAAAAESAAA0vJskEENrT48Hp3F38gphAATprJd_AAA=

{
    "recurrence": {
        "pattern": {
            "type": "absoluteMonthly",
            "interval": 1,
            "month": 0,
            "dayOfMonth": 20,
            "daysOfWeek": [],
            "firstDayOfWeek": "sunday",
            "index": "first"
        },
        "range": {
            "type": "noEnd",
            "startDate": "2024-09-20",
            "endDate": "0001-01-01",
            "recurrenceTimeZone": "UTC",
            "numberOfOccurrences": 0
        }
    }
}
{
    "error": {
        "code": "invalidRequest",
        "message": "Invalid JSON, Error converting value \"2024-09-20\" to type 'Microsoft.OData.Edm.Date'. Path 'recurrence.range.startDate', line 1, position 197.",
        "innerError": {
            "code": "InvalidModel",
            "date": "2024-09-24T12:15:44",
            "request-id": "0fcfff48-ba8d-40a8-8c9a-bde199ee7d95",
            "client-request-id": "5c7103f4-15ad-3e89-75fa-f0ad42718ed3"
        }
    }
}

However, POST works fine, I can create a ToDoTask with recurrence, just can't PATCH it.

{
    "title": "Recurring Task Example xxx",
    "dueDateTime": {
        "dateTime": "2023-09-25T12:00:00.0000000",
        "timeZone": "UTC"
    },
    "recurrence": {
        "pattern": {
            "type": "weekly",
            "interval": 1
        },
        "range": {
            "type": "endDate",
            "startDate": "2023-09-25",
            "endDate": "2024-09-25"
        }
    }
}