Microsoft图表批量插入新任务和更新详细信息

时间:2018-04-17 10:56:32

标签: odata microsoft-graph

创建任务的当前步骤是

POST /planner/tasks

GET /planner/tasks/{id from post call}/details

PATCH /planner/tasks/{id from post call}/details
If-Match: {etag from get call}

但我想使用https://developer.microsoft.com/en-us/graph/docs/concepts/json_batching

在单个通话中批处理三个步骤

根据odata v4引用http://docs.oasis-open.org/odata/odata-json-format/v4.01/csprd02/odata-json-format-v4.01-csprd02.html#sec_ReferencingNewEntities,我们可以使用${id of other request}

引用同一批次调用中的实体
{
    "requests": [
        {
            "id": "task",
            "url": "/planner/tasks",
            "body": {
                "title": "asff",
                "appliedCategories": {
                    "category5": true
                },
                "planId": "mSV7ODf3g0iTJrUtsNcvHZYAB-ZW",
                "bucketId": "WFN6kxMykE-4xxqLUh1uS5YALCWq",
                "assignments": {
                    "4393baf8-8a52-4164-bf93-b1cba5130329": {
                        "@odata.type": "#microsoft.graph.plannerAssignment",
                        "orderHint": " !"
                    }
                },
                "dueDateTime": "2018-04-23T18:30:00.000Z"
            },
            "method": "POST",
            "headers": {
                "Content-Type": "application/json"
            }
        },
        {
            "id": "getDetail",
            "method": "GET",
            "dependsOn": [
                "task"
            ],
            "url": "/planner/tasks/$task/details"
        },
        {
            "id": "patchDetail",
            "dependsOn": [
                "getDetail"
            ],
            "url": "/planner/tasks/$task/details",
            "method": "PATCH",
            "headers": {
                "Content-Type": "application/json",
                "if-match": "$getDetail"
            },
            "body": {
                "description": "gwrthbetrhnety"
                }
            }
        }
    ]
}

但是获取详细信息调用失败并显示错误

{
    "id": "getDetail",
    "status": 400,
    "body": {
        "error": {
            "code": "BadRequest",
            "message": "The request URI is not valid. Since the segment 'tasks' refers to a collection, this must be the last segment in the request URI or it must be followed by an function or action that can be bound to it otherwise all intermediate segments must refer to a single resource.",
            "innerError": {
                "request-id": "a46ce528-993f-4cff-865e-98b2b98d5f23",
                "date": "2018-04-17T10:38:29"
            }
        }
    }
}

我在这里做错了什么

0 个答案:

没有答案