Office365 使用Microsoft Graph创建和更新组返回500-内部服务器错误

Office365 使用Microsoft Graph创建和更新组返回500-内部服务器错误,office365,office365api,microsoft-graph-api,Office365,Office365api,Microsoft Graph Api,我是REST编程新手,我正在尝试使用Microsoft Graph API创建和更新Office 365组,但对于这两个操作,我都会收到一个500内部服务器错误响应,没有说明什么问题 以下是创建新组的简化代码: public async Task<Group> CreateGroup() { string accessToken = GetAccessToken(); // method for getting the Graph token string newG

我是REST编程新手,我正在尝试使用Microsoft Graph API创建和更新Office 365组,但对于这两个操作,我都会收到一个500内部服务器错误响应,没有说明什么问题

以下是创建新组的简化代码:

public async Task<Group> CreateGroup()
{
    string accessToken = GetAccessToken(); // method for getting the Graph token

    string newGroup =   "{" +
                            "\"group\": " +
                            "{" +
                                "\"description\": \"description-value\"," +
                                "\"displayName\": \"displayName-value\"," +
                                "\"groupTypes\": [" +
                                   "\"Unified\"" +
                                "]," +
                                "\"mail\": \"somemail@tenantname.com\"," +
                                "\"mailEnabled\": true," +
                                "\"mailNickname\": \"mailNickname-value\"," +
                                "\"securityEnabled\": \"false\"" +
                            "}" +
                        "}";

    using (var client = new HttpClient())
    {
        using (var request = new HttpRequestMessage(HttpMethod.Post, https://graph.microsoft.com/v1.0/groups))
        {
            request.Headers.Authorization = new AuthenticationHeaderValue("Bearer", accessToken);

            request.Content = new StringContent(JsonConvert.SerializeObject(newGroup), Encoding.UTF8, "application/json");

            using (HttpResponseMessage response = await client.SendAsync(request))
            {
                if (response.IsSuccessStatusCode)
                {
                    // parse and return content
                }
                else 
                {
                    // handle error
                }
            }
        }
    }
}

我在这里看到过两篇文章,其中人们成功地创建了统一的组,所以我猜这是我在代码中找不到的东西。还有其他人遇到过相同的错误吗?

请求不应将所有组属性包装在“group”元素中。正确的请求有效负载示例为:

{  
    "description": "description-value",
    "displayName": "displayName-value",
    "groupTypes": [
      "Unified"
    ],
    "mailEnabled": true,
    "mailNickname": "mailNickname-value",
    "securityEnabled": false
}
我创建该文档是为了更正文档中使用的示例

{  
    "description": "description-value",
    "displayName": "displayName-value",
    "groupTypes": [
      "Unified"
    ],
    "mailEnabled": true,
    "mailNickname": "mailNickname-value",
    "securityEnabled": false
}