组: validatePropertiesgroup: validateProperties

验证 Office 365 组的显示名称或邮件昵称是否符合命名策略。Validate if an Office 365 group's display name or mail nickname complies with naming policies. 在尝试更新Office 365 组之前, 客户端可以使用 API 来确定显示名称或邮件昵称是否有效。Clients can use the API to determine if a display name or mail nickname is valid before trying to update an Office 365 group. 若要在创建组之前验证属性, 请使用目录对象的validateProperties 函数For validating properties before creating a group, use the validateProperties function for directory objects.

将为显示名称和邮件昵称属性执行以下验证:The following validations are performed for the display name and mail nickname properties:

  1. 验证前缀和后缀命名策略Validate the prefix and suffix naming policy
  2. 验证 "自定义禁止的词语" 策略Validate the custom banned words policy

此 API 在遇到第一次失败时返回。This API returns with the first failure encountered. 如果一个或多个属性失败多次验证, 则仅返回第一个验证失败的属性。If one or more properties fail multiple validations, only the property with the first validation failure is returned. 但是, 如果仅验证前缀和后缀命名策略, 则可以验证邮件别名和显示名称, 并接收验证错误的集合。However, you can validate both the mail nickname and the display name and receive a collection of validation errors if you are only validating the prefix and suffix naming policy.

权限Permissions

要调用此 API,需要以下权限之一。要了解详细信息,包括如何选择权限的信息,请参阅权限One of the following permissions is required to call this API. To learn more, including how to choose permissions, see Permissions.

权限类型Permission type 权限(从最低特权到最高特权)Permissions (from least to most privileged)
委派(工作或学校帐户)Delegated (work or school account) Group.Read.All、Group.ReadWrite.AllGroup.Read.All, Group.ReadWrite.All
委派(个人 Microsoft 帐户)Delegated (personal Microsoft account) 不支持。Not supported.
应用程序Application Group.Read.All、Group.ReadWrite.AllGroup.Read.All, Group.ReadWrite.All

HTTP 请求HTTP request

POST /groups/{id}/validateProperties

请求标头Request headers

名称Name 说明Description
AuthorizationAuthorization Bearer {code}Bearer {code}
Content-TypeContent-Type application/jsonapplication/json

请求正文Request body

在请求正文中,提供具有以下参数的 JSON 对象。In the request body, provide a JSON object with the following parameters.

参数Parameter 类型Type 说明Description
displayNamedisplayName StringString 要验证的组的显示名称。The display name of the group to validate. 属性不是单独需要的。The property is not individually required. 但是, 至少需要一个属性 (displayName 或 mailNickname)。However, at least one property (displayName or mailNickname) is required.
mailNicknamemailNickname StringString 要验证的组的邮件别名。The mail nickname of the group to validate. 属性不是单独需要的。The property is not individually required. 但是, 至少需要一个属性 (displayName 或 mailNickname)。However, at least one property (displayName or mailNickname) is required.
onBehalfOfUserIdonBehalfOfUserId GuidGuid 调用 API 时要模拟的用户的对象 ID。The object ID of the user to impersonate when calling the API. 验证结果针对的是 onBehalfOfUserId 的属性和角色。The validation results are for the onBehalfOfUserId's attributes and roles.

响应Response

如果成功且没有验证错误, 则该方法返回204 No Content响应代码。If successful and there are no validation errors, the method returns 204 No Content response code. 它不在响应正文中返回任何内容。It does not return anything in the response body.

如果请求无效, 该方法将返回400 Bad Request响应代码。If the request is invalid, the method returns 400 Bad Request response code. 有关无效请求的详细信息的错误消息将在响应正文中返回。An error message with details about the invalid request is returned in the response body.

如果存在验证错误。If there is a validation error. 此方法返回422 Unprocessable Entity响应代码。The method returns 422 Unprocessable Entity response code. 响应正文中返回一条错误消息和一组错误详细信息。An error message and a collection of error details is returned in the response body.

示例Examples

这是一个成功的验证请求的示例。This is an example of a successful validation request.

请求Request

POST https://graph.microsoft.com/beta/groups/{id}/validateProperties
Content-type: application/json
Content-length: 132

{
  "displayName": "Myprefix_test_mysuffix",
  "mailNickname": "Myprefix_test_mysuffix",
  "onBehalfOfUserId": "onBehalfOfUserId-value"
}

响应Response

HTTP/1.1 204 No Content

这是包含验证错误的请求的示例。This is an example of a request with validation errors.

请求Request

POST https://graph.microsoft.com/beta/groups/{id}/validateProperties
Content-type: application/json
Content-length: 128

{
  "displayName": "MyPrefix_test_mysuffix",
  "mailNickname": "MyPrefix_test_mysuffix"
}

响应Response

HTTP/1.1 422
Content-type: application/json
Content-length: 223

{
  "error": {
    "code": "Request_UnprocessableEntity",
    "message": "The values provided contain one or more validation errors.",
    "innerError": {
      "request-id": "id-value",
      "date": "date-value"
    },
    "details": [
      {
        "target": "mailNickname",
        "code": "PropertyConflict",
        "message": "Another object with the same value for property mailNickname already exists."
      }
    ]
  }
}