创建 identityApiConnector

命名空间:microsoft.graph

创建新的 identityApiConnector 对象。

权限

要调用此 API,需要以下权限之一。要了解详细信息,包括如何选择权限的信息,请参阅权限

权限类型 权限(从最低特权到最高特权)
委派(工作或学校帐户) APIConnectors.ReadWrite.All
委派(个人 Microsoft 帐户) 不支持。
应用程序 APIConnectors.ReadWrite.All

工作或学校帐户需要属于以下角色之一:

  • 全局管理员
  • 外部标识用户Flow管理员

HTTP 请求

POST /identity/apiConnectors

请求标头

名称 说明
Authorization Bearer {token}。必需。
Content-Type application/json. Required.

请求正文

在请求正文中,提供 identityApiConnector 对象的 JSON 表示形式。

下表显示创建 identityApiConnector 时所需的属性。

属性 类型 说明
displayName String API 连接器的名称。
targetUrl 字符串 要调用的 API 终结点的 URL。
authenticationConfiguration apiAuthenticationConfigurationBase 描述用于调用 API 的身份验证配置详细信息的对象。 支持基本 身份验证 和 PKCS 12 客户端 证书。

响应

如果成功,此方法在响应 201 Created 正文中返回 响应代码和 identityApiConnector 对象。

示例

示例 1:使用基本身份验证创建 API 连接器

请求

下面展示了示例请求。

POST https://graph.microsoft.com/v1.0/identity/apiConnectors
Content-Type: application/json

{
    "displayName":"Test API",
    "targetUrl":"https://someapi.com/api",
    "authenticationConfiguration": {
      "@odata.type":"#microsoft.graph.basicAuthentication",
      "username": "MyUsername",
      "password": "MyPassword"
    }
}

响应

下面展示了示例响应。

注意: 为了提高可读性,可能缩短了此处显示的响应对象。

HTTP/1.1 201 Created
Content-Type: application/json

{
    "@odata.context": "https://graph.microsoft.com/v1.0/$metadata#identity/apiConnectors/$entity",
    "id":"45715bb8-13f9-4bf6-927f-ef96c102d394",
    "displayName": "Test API",
    "targetUrl": "https://someapi.com/api",
    "authenticationConfiguration": {
        "@odata.type": "#microsoft.graph.basicAuthentication",
        "username": "MyUsername",
        "password": "******"
    }
}

示例 2:使用客户端证书身份验证创建 API 连接器

请求

下面展示了示例请求。

注意: authenticationConfiguration 请求中的 类型为 microsoft.graph.pkcs12certificate,表示上载或创建时所需的证书配置。

POST https://graph.microsoft.com/v1.0/identity/apiConnectors
Content-Type: application/json

{
    "displayName":"Test API",
    "targetUrl":"https://someotherapi.com/api",
    "authenticationConfiguration": {
        "@odata.type":"#microsoft.graph.pkcs12Certificate",
        "pkcs12Value": "eyJhbGciOiJSU0EtT0FFUCIsImVuYyI6IkEyNTZHQ00ifQ...kDJ04sJShkkgjL9Bm49plA",
        "password": "CertificatePassword"
    }
}

响应

下面展示了示例响应。

注意: authenticationConfiguration 响应中的 类型为 microsoft.graph.clientCertificateAuthentication ,因为这表示已上载证书的公共信息。

HTTP/1.1 201 Created
Content-Type: application/json

{
    "@odata.context": "https://graph.microsoft.com/v1.0/$metadata#identity/apiConnectors/$entity",
    "id":"45715bb8-13f9-4bf6-927f-ef96c102d394",
    "displayName": "Test API",
    "targetUrl": "https://someotherapi.com/api",
    "authenticationConfiguration": {
        "@odata.type": "#microsoft.graph.clientCertificateAuthentication",
        "certificateList": [
            {
                "thumbprint": "0EB255CC895477798BA418B378255204304897AD",
                "notAfter": 1666350522,
                "notBefore": 1508670522,
                "isActive": true
            }
        ]
    }
}