打印机:创建printer: create

命名空间:microsoft.graphNamespace: microsoft.graph

重要

/betaMicrosoft Graph 中的版本下的 api 可能会发生更改。APIs under the /beta version in Microsoft Graph are subject to change. 不支持在生产应用程序中使用这些 API。Use of these APIs in production applications is not supported.

创建 (注册) 使用通用打印服务的打印机。Create (register) a printer with the Universal Print service. 这是一个长时间运行的操作,因此它返回可用于跟踪和验证打印机注册的 printerCreateOperationThis is a long-running operation and as such, it returns a printerCreateOperation that can be used to track and verify the registration of the printer.

权限Permissions

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

除了以下权限之外,用户的租户还必须具有活动的通用打印订阅。In addition to the following permissions, the user's tenant must have an active Universal Print subscription. 登录用户必须是 打印机管理员The signed in user must be a Printer Administrator.

权限类型Permission type 权限(从最低特权到最高特权)Permissions (from least to most privileged)
委派(工作或学校帐户)Delegated (work or school account) "完全控制"、"全部"、"全打印机"Printer.Create, Printer.ReadWrite.All, Printer.FullControl.All
委派(个人 Microsoft 帐户)Delegated (personal Microsoft account) 不支持。Not Supported.
应用程序Application 不支持。Not supported.

HTTP 请求HTTP request

POST /print/printers/create

请求标头Request headers

名称Name 说明Description
AuthorizationAuthorization Bearer {token}。必需。Bearer {token}. Required.
Content-typeContent-type application/json. Required.application/json. Required.

请求正文Request body

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

参数Parameter 类型Type 说明Description 是否必需?Required?
displayNamedisplayName StringString 要分配给打印机的显示名称。The display name to assign to the printer. Yes
manufacturermanufacturer StringString 打印机的制造商。The manufacturer of the printer. Yes
modelmodel StringString 打印机的型号。The model of the printer. Yes
physicalDeviceIdphysicalDeviceId StringString 打印机的物理设备 UUID。The physical device UUID of the printer. 如果属性为 true,则为必需 hasPhysicalDeviceRequired if the hasPhysicalDevice property is true. No
hasPhysicalDevicehasPhysicalDevice 布尔值Boolean 如果打印机具有物理输出设备,则为 True,否则为 false。True if the printer has physical output device, false otherwise. 如果省略,则默认值为 true。If omitted, the default value is true. No
certificateSigningRequestcertificateSigningRequest printCertificateSigningRequestprintCertificateSigningRequest X.509 证书签名请求 (CSR) 为打印机创建并使用的证书来标识自己。The X.509 Certificate Signing Request (CSR) for the certificate created and used by the printer to identify itself. Yes
connectorIdconnectorId StringString 充当打印机代理的连接器的 Id。Id of Connector acting as proxy to the printer. No

响应Response

如果成功,此方法将 202 Accepted 在标头中返回响应代码和关联的 printerCreateOperation 的链接 Operation-LocationIf successful, this method returns a 202 Accepted response code and a link to the associated printerCreateOperation in the Operation-Location header.

向链接的 URL 发出 GET 请求可用于获取正在进行的打印机注册的状态。Making a GET request to the linked URL can be used to get the status of an ongoing printer registration. 成功完成打印机注册后,对链接的 URL 的 GET 请求将包含创建的打印机对象和已注册的证书。Once printer registration has completed successfully, a GET request to the linked URL will contain the created printer object and registered certificate.

示例Example

请求Request

下面展示了示例请求。The following is an example of the request. 若要获取有关创建 (CSR) 所需的证书签名请求的帮助,请参阅 CSR 生成代码示例For help creating the required Certificate Signing Request (CSR), see the CSR generation code sample.

POST https://graph.microsoft.com/beta/print/printers/create
Content-type: application/json
Content-length: 319

{
  "displayName": "Test Printer",
  "manufacturer": "Test Printer Manufacturer",
  "model": "Test Printer Model",
  "physicalDeviceId": null,
  "hasPhysicalDevice": false,
  "certificateSigningRequest": { 
    "content": "{content}",
    "transportKey": "{sampleTransportKey}"
  },
  "connectorId": null
}

响应Response

下面展示了示例响应。The following is an example of the response.

HTTP/1.1 202 Accepted
Operation-Location: https://graph.microsoft.com/beta/print/operations/f221760a-52e8-4c11-b8c5-5dfaef3a49db
Retry-After: 5