向链接 URL 发出 GET 请求,以获取正在进行的打印机注册状态。 打印机注册成功完成后,对链接 URL 的 GET 请求将包含创建的打印机对象和已注册的证书。
POST https://graph.microsoft.com/v1.0/print/printers/create
Content-Type: application/json
{
"displayName": "Test Printer",
"manufacturer": "Test Printer Manufacturer",
"model": "Test Printer Model",
"physicalDeviceId": null,
"hasPhysicalDevice": false,
"certificateSigningRequest": {
"content": "{content}",
"transportKey": "{sampleTransportKey}"
},
"connectorId": null
}
// Code snippets are only available for the latest version. Current version is 5.x
// Dependencies
using Microsoft.Graph.Print.Printers.Create;
using Microsoft.Graph.Models;
var requestBody = new CreatePostRequestBody
{
DisplayName = "Test Printer",
Manufacturer = "Test Printer Manufacturer",
Model = "Test Printer Model",
PhysicalDeviceId = null,
HasPhysicalDevice = false,
CertificateSigningRequest = new PrintCertificateSigningRequest
{
Content = "{content}",
TransportKey = "{sampleTransportKey}",
},
ConnectorId = null,
};
// To initialize your graphClient, see https://learn.microsoft.com/en-us/graph/sdks/create-client?from=snippets&tabs=csharp
await graphClient.Print.Printers.Create.PostAsync(requestBody);
有关如何将 SDK 添加到项目并创建 authProvider 实例的详细信息,请参阅 SDK 文档。
mgc print printers create post --body '{\
"displayName": "Test Printer",\
"manufacturer": "Test Printer Manufacturer",\
"model": "Test Printer Model",\
"physicalDeviceId": null,\
"hasPhysicalDevice": false,\
"certificateSigningRequest": { \
"content": "{content}",\
"transportKey": "{sampleTransportKey}"\
},\
"connectorId": null\
}\
'
有关如何将 SDK 添加到项目并创建 authProvider 实例的详细信息,请参阅 SDK 文档。
// Code snippets are only available for the latest major version. Current major version is $v1.*
// Dependencies
import (
"context"
msgraphsdk "github.com/microsoftgraph/msgraph-sdk-go"
graphprint "github.com/microsoftgraph/msgraph-sdk-go/print"
graphmodels "github.com/microsoftgraph/msgraph-sdk-go/models"
//other-imports
)
requestBody := graphprint.NewCreatePostRequestBody()
displayName := "Test Printer"
requestBody.SetDisplayName(&displayName)
manufacturer := "Test Printer Manufacturer"
requestBody.SetManufacturer(&manufacturer)
model := "Test Printer Model"
requestBody.SetModel(&model)
physicalDeviceId := null
requestBody.SetPhysicalDeviceId(&physicalDeviceId)
hasPhysicalDevice := false
requestBody.SetHasPhysicalDevice(&hasPhysicalDevice)
certificateSigningRequest := graphmodels.NewPrintCertificateSigningRequest()
content := "{content}"
certificateSigningRequest.SetContent(&content)
transportKey := "{sampleTransportKey}"
certificateSigningRequest.SetTransportKey(&transportKey)
requestBody.SetCertificateSigningRequest(certificateSigningRequest)
connectorId := null
requestBody.SetConnectorId(&connectorId)
// To initialize your graphClient, see https://learn.microsoft.com/en-us/graph/sdks/create-client?from=snippets&tabs=go
graphClient.Print().Printers().Create().Post(context.Background(), requestBody, nil)
有关如何将 SDK 添加到项目并创建 authProvider 实例的详细信息,请参阅 SDK 文档。
// Code snippets are only available for the latest version. Current version is 6.x
GraphServiceClient graphClient = new GraphServiceClient(requestAdapter);
com.microsoft.graph.print.printers.create.CreatePostRequestBody createPostRequestBody = new com.microsoft.graph.print.printers.create.CreatePostRequestBody();
createPostRequestBody.setDisplayName("Test Printer");
createPostRequestBody.setManufacturer("Test Printer Manufacturer");
createPostRequestBody.setModel("Test Printer Model");
createPostRequestBody.setPhysicalDeviceId(null);
createPostRequestBody.setHasPhysicalDevice(false);
PrintCertificateSigningRequest certificateSigningRequest = new PrintCertificateSigningRequest();
certificateSigningRequest.setContent("{content}");
certificateSigningRequest.setTransportKey("{sampleTransportKey}");
createPostRequestBody.setCertificateSigningRequest(certificateSigningRequest);
createPostRequestBody.setConnectorId(null);
graphClient.print().printers().create().post(createPostRequestBody);
有关如何将 SDK 添加到项目并创建 authProvider 实例的详细信息,请参阅 SDK 文档。
const options = {
authProvider,
};
const client = Client.init(options);
const create = {
displayName: 'Test Printer',
manufacturer: 'Test Printer Manufacturer',
model: 'Test Printer Model',
physicalDeviceId: null,
hasPhysicalDevice: false,
certificateSigningRequest: {
content: '{content}',
transportKey: '{sampleTransportKey}'
},
connectorId: null
};
await client.api('/print/printers/create')
.post(create);
有关如何将 SDK 添加到项目并创建 authProvider 实例的详细信息,请参阅 SDK 文档。
<?php
use Microsoft\Graph\GraphServiceClient;
use Microsoft\Graph\Generated\Print\Printers\Create\CreatePostRequestBody;
use Microsoft\Graph\Generated\Models\PrintCertificateSigningRequest;
$graphServiceClient = new GraphServiceClient($tokenRequestContext, $scopes);
$requestBody = new CreatePostRequestBody();
$requestBody->setDisplayName('Test Printer');
$requestBody->setManufacturer('Test Printer Manufacturer');
$requestBody->setModel('Test Printer Model');
$requestBody->setPhysicalDeviceId(null);
$requestBody->setHasPhysicalDevice(false);
$certificateSigningRequest = new PrintCertificateSigningRequest();
$certificateSigningRequest->setContent('{content}');
$certificateSigningRequest->setTransportKey('{sampleTransportKey}');
$requestBody->setCertificateSigningRequest($certificateSigningRequest);
$requestBody->setConnectorId(null);
$graphServiceClient->escapedPrint()->printers()->create()->post($requestBody)->wait();
有关如何将 SDK 添加到项目并创建 authProvider 实例的详细信息,请参阅 SDK 文档。
Import-Module Microsoft.Graph.Devices.CloudPrint
$params = @{
displayName = "Test Printer"
manufacturer = "Test Printer Manufacturer"
model = "Test Printer Model"
physicalDeviceId = $null
hasPhysicalDevice = $false
certificateSigningRequest = @{
content = '{content}'
transportKey = '{sampleTransportKey}'
}
connectorId = $null
}
New-MgPrintPrinter -BodyParameter $params
有关如何将 SDK 添加到项目并创建 authProvider 实例的详细信息,请参阅 SDK 文档。
# Code snippets are only available for the latest version. Current version is 1.x
from msgraph import GraphServiceClient
from msgraph.generated.print.printers.create.create_post_request_body import CreatePostRequestBody
from msgraph.generated.models.print_certificate_signing_request import PrintCertificateSigningRequest
# To initialize your graph_client, see https://learn.microsoft.com/en-us/graph/sdks/create-client?from=snippets&tabs=python
request_body = CreatePostRequestBody(
display_name = "Test Printer",
manufacturer = "Test Printer Manufacturer",
model = "Test Printer Model",
physical_device_id = None,
has_physical_device = False,
certificate_signing_request = PrintCertificateSigningRequest(
content = "{content}",
transport_key = "{sampleTransportKey}",
),
connector_id = None,
)
await graph_client.print.printers.create.post(request_body)
有关如何将 SDK 添加到项目并创建 authProvider 实例的详细信息,请参阅 SDK 文档。