プリンター: 作成
[アーティクル]
10/31/2023
8 人の共同作成者
フィードバック
この記事の内容
名前空間: microsoft.graph
ユニバーサル 印刷サービスを使用してプリンターを作成 (登録) します。 これは実行時間の長い操作であるため、プリンターの登録を追跡および確認するために使用できる printerCreateOperation が返されます。
プリンターを作成するために必要な証明書署名要求 (CSR) の作成については、 CSR 生成コードサンプル を参照してください。
この API は、次の国内クラウド展開 で使用できます。
グローバル サービス
米国政府機関 L4
米国政府機関 L5 (DOD)
21Vianet が運営する中国
✅
✅
✅
❌
アクセス許可
この API の最小特権としてマークされているアクセス許可またはアクセス許可を選択します。 アプリで必要な場合にのみ 、より高い特権のアクセス許可またはアクセス許可を使用します。 委任されたアクセス許可とアプリケーションのアクセス許可の詳細については、「 アクセス許可の種類 」を参照してください。 これらのアクセス許可の詳細については、 アクセス許可のリファレンスを参照してください 。
アクセス許可の種類
最小特権アクセス許可
特権の高いアクセス許可
委任 (職場または学校のアカウント)
Printer.Create
Printer.FullControl.All、Printer.ReadWrite.All
委任 (個人用 Microsoft アカウント)
サポートされていません。
サポートされていません。
アプリケーション
サポートされていません。
サポートされていません。
HTTP 要求
POST /print/printers/create
名前
説明
Authorization
ベアラー {token}。 必須です。 認証と承認 の詳細については、こちらをご覧ください。
Content-Type
application/json. 必須です。
要求本文
要求本文で、パラメーターの JSON 表現を指定します。
次の表に、このアクションで使用できるパラメーターを示します。
パラメーター
型
説明
必須
displayName
String
プリンターに割り当てる表示名。
はい
manufacturer
String
プリンターの製造元。
はい
model
String
プリンターのモデル。
はい
physicalDeviceId
String
プリンターの物理デバイス UUID。 プロパティが true の hasPhysicalDevice
場合は必須です。
いいえ
hasPhysicalDevice
ブール型
プリンターに物理出力デバイスがある場合は True、それ以外の場合は false。 省略した場合、既定値は true です。
いいえ
certificateSigningRequest
printCertificateSigningRequest
プリンターによって作成され、プリンターが自身を識別するために使用する証明書の X.509 証明書署名要求 (CSR)。
はい
connectorId
String
プリンターへのプロキシとして機能するコネクタの ID。
いいえ
応答
成功した場合、このメソッドは 202 Accepted
応答コードと、ヘッダー内の関連する printerCreateOperation へのリンクを Operation-Location
返します。
リンクされた 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\Models\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 のドキュメント を参照してください。
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
graph_client = GraphServiceClient(credentials, scopes)
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 のドキュメント を参照してください。
応答
HTTP/1.1 202 Accepted
Operation-Location: https://graph.microsoft.com/v1.0/print/operations/f221760a-52e8-4c11-b8c5-5dfaef3a49db
Retry-After: 5