Microsoft Graph Batch API 并发请求减少至 4 个,而 Outlook 的并发请求为 200 个

Kar*_*hik 6 outlook outlook-restapi microsoft-graph-sdks microsoft-graph-api

我们使用 Outlook Batch API在单个 HTTP 批处理请求中发送多个 Outlook REST 请求。在 Outlook Batch API 中,我们在同一批 HTTP 请求中发出 200 个请求,并且所有并发请求都成功。而如果我们在图API中执行相同的操作,则只有 4 个并发请求成功,因为图 API 中仅支持 4 个并发请求(附加请求和响应)。

我们有这样的情况,例如一次创建 10000 个事件(例如用户可以从单个用户日历中添加/删除 10000 个项目)。

因此,如果将 Graph API 批量限制设置为与 Outlook API 相同(200 个并发请求),将会有很大帮助。

样品请求:

{
    "requests": [
        {
            "url": "/me/calendars",
            "method": "POST",
            "id": "1",
            "headers": {
                "Content-Type": "application/json"
            },
            "body": {
                "name": "test1s"
            }
        },
        {
            "url": "/me/calendars",
            "method": "POST",
            "id": "2",
            "headers": {
                "Content-Type": "application/json"
            },
            "body": {
                "name": "test2"
            }
        },
        {
            "url": "/me/calendars",
            "method": "POST",
            "id": "3",
            "headers": {
                "Content-Type": "application/json"
            },
            "body": {
                "name": "test3"
            }
        },
        {
            "url": "/me/calendars",
            "method": "POST",
            "id": "4",
            "headers": {
                "Content-Type": "application/json"
            },
            "body": {
                "name": "test4"
            }
        },
        {
            "url": "/me/calendars",
            "method": "POST",
            "id": "5",
            "headers": {
                "Content-Type": "application/json"
            },
            "body": {
                "name": "test5s"
            }
        },
        {
            "url": "/me/calendars",
            "method": "POST",
            "id": "6",
            "headers": {
                "Content-Type": "application/json"
            },
            "body": {
                "name": "test6s"
            }
        },
        {
            "url": "/me/calendars",
            "method": "POST",
            "id": "7",
            "headers": {
                "Content-Type": "application/json"
            },
            "body": {
                "name": "test7s"
            }
        }
    ]
}
Run Code Online (Sandbox Code Playgroud)

回复:

{
    "responses": [
        {
            "id": "6",
            "status": 429,
            "headers": {
                "Retry-After": "1",
                "Cache-Control": "private",
                "Content-Type": "application/json"
            },
            "body": {
                "error": {
                    "code": "ApplicationThrottled",
                    "message": "Application is over its MailboxConcurrency limit.",
                    "innerError": {
                        "date": "2022-08-11T06:21:56",
                        "request-id": "e09afe6b-25d6-4cdc-93f5-0539d6e8b9c6",
                        "client-request-id": "efe22070-473c-28bd-d1bf-ad43bb9f753f"
                    }
                }
            }
        },
        {
            "id": "7",
            "status": 429,
            "headers": {
                "Retry-After": "1",
                "Cache-Control": "private",
                "Content-Type": "application/json"
            },
            "body": {
                "error": {
                    "code": "ApplicationThrottled",
                    "message": "Application is over its MailboxConcurrency limit.",
                    "innerError": {
                        "date": "2022-08-11T06:21:56",
                        "request-id": "e09afe6b-25d6-4cdc-93f5-0539d6e8b9c6",
                        "client-request-id": "efe22070-473c-28bd-d1bf-ad43bb9f753f"
                    }
                }
            }
        },
        {
            "id": "4",
            "status": 429,
            "headers": {
                "Retry-After": "1",
                "Cache-Control": "private",
                "Content-Type": "application/json"
            },
            "body": {
                "error": {
                    "code": "ApplicationThrottled",
                    "message": "Application is over its MailboxConcurrency limit.",
                    "innerError": {
                        "date": "2022-08-11T06:21:56",
                        "request-id": "e09afe6b-25d6-4cdc-93f5-0539d6e8b9c6",
                        "client-request-id": "efe22070-473c-28bd-d1bf-ad43bb9f753f"
                    }
                }
            }
        },
        {
            "id": "5",
            "status": 201,
            "headers": {
                "Location": x"https://outlook.office.com/api/v2.0/Users('xxxx')/Calendars('xxxx')",
                "Cache-Control": "private",
                "OData-Version": "4.0",
                "Content-Type": "application/json;odata.metadata=minimal;odata.streaming=true;IEEE754Compatible=false;charset=utf-8"
            },
            "body": {
                "@odata.context": "https://graph.microsoft.com/v1.0/$metadata#users('xxxxx')/calendars/$entity",
                "id": "xxx",
                "name": "test5s",
                "color": "auto",
                "hexColor": "",
                "isDefaultCalendar": false,
                "changeKey": "xxxxx",
                "canShare": true,
                "canViewPrivateItems": true,
                "canEdit": true,
                "allowedOnlineMeetingProviders": [
                    "teamsForBusiness"
                ],
                "defaultOnlineMeetingProvider": "teamsForBusiness",
                "isTallyingResponses": false,
                "isRemovable": true,
                "owner": {
                    "name": "xxxx",
                    "address": "xxxx.onmicrosoft.com"
                }
            }
        },
        {
            "id": "2",
            "status": 201,
            "headers": {
                "Location": "https://outlook.office.com/api/v2.0/Users('xxxx')/Calendars('xxxx')",
                "Cache-Control": "private",
                "OData-Version": "4.0",
                "Content-Type": "application/json;odata.metadata=minimal;odata.streaming=true;IEEE754Compatible=false;charset=utf-8"
            },
            "body": {
                "@odata.context": "https://graph.microsoft.com/v1.0/$metadata#users('xx')/calendars/$entity",
                "id": "xxx",
                "name": "test2",
                "color": "auto",
                "hexColor": "",
                "isDefaultCalendar": false,
                "changeKey": "xxxxx",
                "canShare": true,
                "canViewPrivateItems": true,
                "canEdit": true,
                "allowedOnlineMeetingProviders": [
                    "teamsForBusiness"
                ],
                "defaultOnlineMeetingProvider": "teamsForBusiness",
                "isTallyingResponses": false,
                "isRemovable": true,
                "owner": {
                    "name": "xxxx",
                    "address": "xxxxx.onmicrosoft.com"
                }
            }
        },
        {
            "id": "3",
            "status": 201,
            "headers": {
                "Location": "https://outlook.office.com/api/v2.0/Users('xxxx')/Calendars('xxxxx')",
                "Cache-Control": "private",
                "OData-Version": "4.0",
                "Content-Type": "application/json;odata.metadata=minimal;odata.streaming=true;IEEE754Compatible=false;charset=utf-8"
            },
            "body": {
                "@odata.context": "https://graph.microsoft.com/v1.0/$metadata#users('xxx')/calendars/$entity",
                "id": "x",
                "name": "test3",
                "color": "auto",
                "hexColor": "",
                "isDefaultCalendar": false,
                "changeKey": "xxxxxx==",
                "canShare": true,
                "canViewPrivateItems": true,
                "canEdit": true,
                "allowedOnlineMeetingProviders": [
                    "teamsForBusiness"
                ],
                "defaultOnlineMeetingProvider": "teamsForBusiness",
                "isTallyingResponses": false,
                "isRemovable": true,
                "owner": {
                    "name": "xxxx",
                    "address": "xxxxxx.onmicrosoft.com"
                }
            }
        },
        {
            "id": "1",
            "status": 201,
            "headers": {
                "Location": "https://outlook.office.com/api/v2.0/Users('xxxx')/Calendars('xxxx')",
                "Cache-Control": "private",
                "OData-Version": "4.0",
                "Content-Type": "application/json;odata.metadata=minimal;odata.streaming=true;IEEE754Compatible=false;charset=utf-8"
            },
            "body": {
                "@odata.context": "https://graph.microsoft.com/v1.0/$metadata#users('xxxxx')/calendars/$entity",
                "id": "xxxxxx",
                "name": "test1s",
                "color": "auto",
                "hexColor": "",
                "isDefaultCalendar": false,
                "changeKey": "xxxxxxx",
                "canShare": true,
                "canViewPrivateItems": true,
                "canEdit": true,
                "allowedOnlineMeetingProviders": [
                    "teamsForBusiness"
                ],
                "defaultOnlineMeetingProvider": "teamsForBusiness",
                "isTallyingResponses": false,
                "isRemovable": true,
                "owner": {
                    "name": "xxxx",
                    "address": "xxxxx.onmicrosoft.com"
                }
            }
        }
    ]
}
Run Code Online (Sandbox Code Playgroud)

小智 0

此处提到的批处理存在一个已知问题: 在此输入图像描述

以及更多内容: 在此输入图像描述

作为参考,请参阅: https://learn.microsoft.com/en-us/graph/known-issues#json-batching https://learn.microsoft.com/en-us/graph/throtdling#throtdling-和批处理