Dynamics 365 API - 操作 AddMembersTeam

Dynamics 365 API - Action AddMembersTeam

我正在使用 API 将多个用户添加到 Dynamics 中的团队。当我想添加单个用户时,我的代码可以正常工作,但我需要它来添加用户列表。

我正在使用 Python 拨打这些电话。

Here is the documentation I am going off of in Dynamics

这是我的部分代码:

        append_team_url = f"{BASE_DATA_URL}teams({team_guid})/Microsoft.Dynamics.CRM.AddMembersTeam"
    team_data = {
                    "Members": [
                        {
                            "ownerid": users_add
                        }
                    ]
                }
    append_users_response = requests.post(append_team_url, headers=api_headers_no_return, data=json.dumps(team_data))

users_add 是 GUID 的列表:

['85927c2e-52e6-e511-80e7-0050569e0d14', 'ebb0ec50-733f-e811-a964-000d3a34edeb',

'd3d6ec34-df57-e511-80e4-0050569e44e8', '19452bf7-3b57-e511-80e4-0050569e44e8']

我得到的错误:

An error occurred while validating input parameters: Microsoft.OData.ODataException: An unexpected 'StartArray' node was found when reading from the JSON reader. A 'PrimitiveValue' node was expected.\r\n at Microsoft.OData.Json.JsonReaderExtensions.ValidateNodeType(IJsonReader jsonReader, JsonNodeType expectedNodeType)\r\n

如有任何帮助,我们将不胜感激!

我知道我可以在 Python 中循环调用,但根据文档的措辞,似乎可以传递多个用户。

负载应该是这样的,看看 Json 用户数组。 Reference

POST [Organization URI]/api/data/v9.0/teams(team-guid-id)/Microsoft.Dynamics.CRM.AddMembersTeam HTTP/1.1
Accept: application/json
Content-Type: application/json; charset=utf-8
OData-MaxVersion: 4.0
OData-Version: 4.0

{
"Members": [{
"@odata.type": "Microsoft.Dynamics.CRM.systemuser",
"ownerid": "85927c2e-52e6-e511-80e7-0050569e0d14"
},{
"@odata.type": "Microsoft.Dynamics.CRM.systemuser",
"ownerid": "ebb0ec50-733f-e811-a964-000d3a34edeb"
}]
}