I'm trying to update a task in planner using beta graph api.
My call is PATCH: https://graph.microsoft.com/beta/tasks/dBwDqUFHpkCetYiUluQlnJYACAzh
The json object looks like this:
{
"bucketId": "Tbi8MJwWwEu4SUYdrqt235YAEkke",
"title": "New Title"
}
And the response:
Status Code: 412
{
"error": {
"code": "UnknownError",
"message": "",
"innerError": {
"request-id": "43132ef7-9a88-4030-b8ad-873d2dc04ff0",
"date": "2017-02-21T11:03:59"
}
}
}
Now I know that status code 412 means Precondition Failed, and I've set the If-Match Request Header. Do you have any other suggestion?
I've also tried the code in https://graph.microsoft.io/en-us/graph-explorer so it is clear that I'm missing something.
Thank you!
Related
I am trying to update the task in Microsoft planner using Graph API in postman. I have already created a blank task and I am updating the created task using PATCH function to attach a file.
PATCH Request:
PATCH https://graph.microsoft.com/v1.0/planner/tasks/{task-id}/details
Content-type: application/json
Prefer: return=representation
If-Match: W/\"JzEtVGFza0RldGFpbHMgQEBAQEBAQEBAQEBAQEBAVCc=\"
{
"#odata.etag": "W/\"JzEtVGFza0RldGFpbHMgQEBAQEBAQEBAQEBAQEBAVCc=\"",
"previewType": "noPreview",
"references": {
"https%3A//my%2Esharepoint%2Ecom/sites/Test12/Shared Documents/Sample%2Edocx":
{
"#odata.type": "microsoft.graph.plannerExternalReference",
"alias": "Sample.docx",
"lastModifiedBy": {
"user": {
"id": "5442777a-0440-4a2f-9269-21824464e3a1"
}
},
"lastModifiedDateTime": "2022-09-05T11:06:47.6011074Z",
"previewPriority": "0009005756397228702",
"type": "word"
}
}
}
When i sent it it showed 400 Bad Request.
Response Error Message -
{
"error": {
"code": "",
"message": "The request is invalid:\r\nAn unexpected 'StartObject' node was found for property named 'lastModifiedBy' when reading from the JSON reader. A 'PrimitiveValue' node was expected.",
"innerError": {
"date": "2022-09-06T04:49:34",
"request-id": "37001992-fafb-461e-a4f0-9f1dafa34b21",
"client-request-id": "37001992-fafb-461e-a4f0-9f1dafa34b21"
}
}
}
Is there any issue with the body content?
I'm getting the response with invalid JSON (brackets aren't closed) when trying to get the MS ToDo task for the user. Also, API sends HTTP status 200 with that response.
Request/response examples:
https://graph.microsoft.com/v1.0/me/todo/lists/:listID/tasks/:taskID
{
"title": "DELETED",
"createdDateTime": "2020-06-17T18:33:44.3228459Z",
"lastModifiedDateTime": "2020-11-27T11:36:55.8037415Z",
"id": "DELETED",
"linkedResources": [
{
"error": {
"code": "InternalServerError",
"message": "Invalid object within the collection response from workload for navigation property linkedResources with declaring type microsoft.graph.todoTask. Expected a JObject, but got Jtoken type - Null",
"innerError": {
"date": "2021-05-14T03:13:36",
"request-id": "5b9445b0-7405-436a-8179-cac92a8af087",
"client-request-id": "5b9445b0-7405-436a-8179-cac92a8af087"
}
}
}
How can I resolve this issue?
I'm getting an error when I call NextLink from the response of first delta.
Any ideas why it's happens?
first call:
https://graph.microsoft.com/beta/users/4ca91597-4091-4cce-856b-7472b3f9ade1/calendars/AAMkAGM3MDdhNGZlLWRjYTUtNGZkYS04NTcxLTU2OTNkZWEwNDlhYQBGAAAAAAAmh2PA4MC8QpGOM1iWfgeZBwCI_1RC5zxoQrQX6X2piZBLAAAAAAEGAACI_1RC5zxoQrQX6X2piZBLAAAAjD53AAA=/events/delta
response:
{
"#odata.context": "https://graph.microsoft.com/beta/$metadata#Collection(event)",
"#odata.nextLink": "https://graph.microsoft.com/beta/users/4ca91597-4091-4cce-856b-7472b3f9ade1/calendars/AAMkAGM3MDdhNGZlLWRjYTUtNGZkYS04NTcxLTU2OTNkZWEwNDlhYQBGAAAAAAAmh2PA4MC8QpGOM1iWfgeZBwCI_1RC5zxoQrQX6X2piZBLAAAAAAEGAACI_1RC5zxoQrQX6X2piZBLAAAAjD53AAA=/events/delta?$skiptoken=S-9EQM7OmIraj-ou9n4yBgQa6fEPxPaBcX7TFg2kKSyrl9s4t08HSSZnFF-gwy4A9E6Yg7ADWLv-z3JJ4D5p_galSKYHzmiN98EJV1ewagGy4vLP_Ccf6Ry5MQoXRx_NxwVr9hFfl2aiymXlEAMXUSGMaX9Yc7O2q6czmAFcCr_ZEL7TGy0sQqgOA7UzNZ64ocJyQRBMUjvuE19KlhqPkA.XaSRYkwmW-IAiW8ABt7Qi1gz7aHGDe2uF-m2RdF2lLM
...}
and on call NextLink I'm getting error:
{
"error": {
"code": "InvalidDeltaToken",
"message": "The value 'NCZUMk42WmtGWmFqZFdSVXh1VUVkb1EzUkNabkJtWVcxS2EwVnpRVUZPVmtWelJEQkNRVUZCUVE9PQ=='
of parameter '$deltaToken' is invalid.",
"innerError": {
"date": "2020-09-27T19:04:42",
"request-id": "6897b163-5d66-4223-8c01-ab40a0417c35",
"client-request-id": "3455e667-c7e7-9c6d-e18e-5c94c37150c8"
}
} }
UPD.1
problem with header:
rPrefer = odata.maxpagesize=50
if you are MS's developer please open ticket.
https://graph.microsoft.com/v1.0/me/onenote/pages/{id}/content
is returning
{
"error": {
"code": "19999",
"message": "Something failed, the API cannot share any more information at the time of the request.",
"innerError": {
"request-id": "571dbc03-154a-4ece-aa7b-1fb05c8c31ce",
"date": "2017-07-11T22:49:01"
}
}
}
Sorry Namrata. Looks like we have a bug. Thanks for reporting. I will fix it and get back to you soon.
When using the Graph API I can successfully create a task, I then wish to update the task details, specifically the description and to add some references.
I'm following the documentation here https://graph.microsoft.io/en-us/docs/api-reference/beta/api/taskdetails_update
I add the request headers, Authentication Bearer, If-Match using the eTag from when I created the task. The URL is:
https://graph.microsoft.com/beta/tasks/6oqAlz30WE66F915zUcSepYAM2ki/details
Http method used is PATCH
Body is:
{
"description": "My Task Title description",
"references": {
"https://tenant.sharepoint.com/teams/teamsite/_layouts/15/WopiFrame.aspx?sourcedoc={521F1D0F-397D-4163-BB16-7C9EF436650B}&file=Release Notes.one&action=view&DefaultItemOpen=1": {
"alias": "OneNote",
"type": "OneNote"
}
}
}
Http response is:
StatusCode: 400, ReasonPhrase: 'Bad Request'
Response Content is:
{
"error": {
"code": "",
"message": "The request is invalid.",
"innerError": {
"request-id": "4e2eae7d-9587-4a69-8c9d-40c5d571190a",
"date": "2016-06-24T10:57:33"
}
}
}
Any ideas as to what I may be doing wrong here?
Coding in C# .Net using HttpClient, HttpRequestMessage.
The URL in the references object needs to be encoded, that's it. i.e.
{
"description": "My Task Title description",
"references": {
"https%3A%2F%2Ftenant.sharepoint.com%2Fteams%2Fteamsite%2F_layouts%2F15%2FWopiFrame.aspx%3Fsourcedoc%3D%7B521F1D0F-397D-4163-BB16-7C9EF436650B%7D%26file%3DRelease+Notes.one%26action%3Dview%26DefaultItemOpen%3D1": {
"alias": "OneNote",
"type": "OneNote"
}
}
}