プリンター: 作成
-
[アーティクル]
-
-
名前空間: microsoft.graph
ユニバーサル 印刷サービスを使用してプリンターを作成 (登録) します。 これは長時間実行される操作であり、プリンターの登録を追跡および確認するために使用できる printerCreateOperation を返します。
プリンターを作成するために必要な証明書署名要求 (CSR) の作成については 、CSR 生成コード サンプルを参照してください。
アクセス許可
この API を呼び出すには、次のいずれかのアクセス許可が必要です。アクセス許可の選択方法などの詳細については、「アクセス許可」を参照してください。
次のアクセス許可に加えて、ユーザーのテナントにアクティブなユニバーサル印刷サブスクリプションが必要です。 サインインしているユーザーはプリンター管理者 である必要があります。
| アクセス許可の種類 |
アクセス許可 (特権の小さいものから大きいものへ) |
| 委任 (職場または学校のアカウント) |
Printer.Create、Printer.ReadWrite.All、Printer.FullControl.All |
| 委任 (個人用 Microsoft アカウント) |
サポートされていません。 |
| アプリケーション |
サポートされていません。 |
HTTP 要求
POST /print/printers/create
| 名前 |
説明 |
| Authorization |
ベアラー {token}。必須。 |
| Content-Type |
application/json. Required. |
要求本文
要求本文で、パラメーターの JSON 表記を指定します。
次の表に、このアクションで使用できるパラメーターを示します。
| パラメーター |
型 |
説明 |
必須 |
| displayName |
文字列 |
プリンターに割り当てる表示名。 |
はい |
| manufacturer |
String |
プリンターの製造元。 |
はい |
| model |
String |
プリンターのモデル。 |
はい |
| physicalDeviceId |
文字列 |
プリンターの物理デバイス UUID。 プロパティが true hasPhysicalDevice の場合は必須です。 |
不要 |
| hasPhysicalDevice |
ブール値 |
プリンターに物理出力デバイスがある場合は True、それ以外の場合は false。 省略すると、既定値は true になります。 |
不要 |
| certificateSigningRequest |
printCertificateSigningRequest |
プリンターが作成して識別するために使用する証明書の X.509 証明書署名要求 (CSR)。 |
はい |
| connectorId |
文字列 |
プリンターのプロキシとして機能するコネクタの 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
}
GraphServiceClient graphClient = new GraphServiceClient( authProvider );
var displayName = "Test Printer";
var manufacturer = "Test Printer Manufacturer";
var model = "Test Printer Model";
String physicalDeviceId = null;
var hasPhysicalDevice = false;
var certificateSigningRequest = new PrintCertificateSigningRequestObject
{
Content = "{content}",
TransportKey = "{sampleTransportKey}"
};
String connectorId = null;
await graphClient.Print.Printers
.Create(displayName,manufacturer,model,certificateSigningRequest,physicalDeviceId,hasPhysicalDevice,connectorId)
.Request()
.PostAsync();
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 のドキュメントを参照してください。
MSHTTPClient *httpClient = [MSClientFactory createHTTPClientWithAuthenticationProvider:authenticationProvider];
NSString *MSGraphBaseURL = @"https://graph.microsoft.com/v1.0/";
NSMutableURLRequest *urlRequest = [NSMutableURLRequest requestWithURL:[NSURL URLWithString:[MSGraphBaseURL stringByAppendingString:@"/print/printers/create"]]];
[urlRequest setHTTPMethod:@"POST"];
[urlRequest setValue:@"application/json" forHTTPHeaderField:@"Content-Type"];
NSMutableDictionary *payloadDictionary = [[NSMutableDictionary alloc] init];
NSString *displayName = @"Test Printer";
payloadDictionary[@"displayName"] = displayName;
NSString *manufacturer = @"Test Printer Manufacturer";
payloadDictionary[@"manufacturer"] = manufacturer;
NSString *model = @"Test Printer Model";
payloadDictionary[@"model"] = model;
payloadDictionary[@"physicalDeviceId"] = physicalDeviceId;
BOOL hasPhysicalDevice = NO;
payloadDictionary[@"hasPhysicalDevice"] = hasPhysicalDevice;
MSGraphPrintCertificateSigningRequest *certificateSigningRequest = [[MSGraphPrintCertificateSigningRequest alloc] init];
[certificateSigningRequest setContent:@"{content}"];
[certificateSigningRequest setTransportKey:@"{sampleTransportKey}"];
payloadDictionary[@"certificateSigningRequest"] = certificateSigningRequest;
payloadDictionary[@"connectorId"] = connectorId;
NSData *data = [NSJSONSerialization dataWithJSONObject:payloadDictionary options:kNilOptions error:&error];
[urlRequest setHTTPBody:data];
MSURLSessionDataTask *meDataTask = [httpClient dataTaskWithRequest:urlRequest
completionHandler: ^(NSData *data, NSURLResponse *response, NSError *nserror) {
//Request Completed
}];
[meDataTask execute];
SDK をプロジェクトに追加し、authProvider インスタンスを作成する方法の詳細については、SDK のドキュメントを参照してください。
GraphServiceClient graphClient = GraphServiceClient.builder().authenticationProvider( authProvider ).buildClient();
String displayName = "Test Printer";
String manufacturer = "Test Printer Manufacturer";
String model = "Test Printer Model";
Boolean hasPhysicalDevice = false;
PrintCertificateSigningRequest certificateSigningRequest = new PrintCertificateSigningRequest();
certificateSigningRequest.content = "{content}";
certificateSigningRequest.transportKey = "{sampleTransportKey}";
graphClient.print().printers()
.create(PrinterCreateParameterSet
.newBuilder()
.withDisplayName(displayName)
.withManufacturer(manufacturer)
.withModel(model)
.withPhysicalDeviceId(physicalDeviceId)
.withHasPhysicalDevice(hasPhysicalDevice)
.withCertificateSigningRequest(certificateSigningRequest)
.withConnectorId(connectorId)
.build())
.buildRequest()
.post();
SDK をプロジェクトに追加し、authProvider インスタンスを作成する方法の詳細については、SDK のドキュメントを参照してください。
//THE GO SDK IS IN PREVIEW. NON-PRODUCTION USE ONLY
graphClient := msgraphsdk.NewGraphServiceClient(requestAdapter)
requestBody := msgraphsdk.New()
displayName := "Test Printer"
requestBody.SetDisplayName(&displayName)
manufacturer := "Test Printer Manufacturer"
requestBody.SetManufacturer(&manufacturer)
model := "Test Printer Model"
requestBody.SetModel(&model)
requestBody.SetPhysicalDeviceId(nil)
hasPhysicalDevice := false
requestBody.SetHasPhysicalDevice(&hasPhysicalDevice)
certificateSigningRequest := msgraphsdk.NewPrintCertificateSigningRequest()
requestBody.SetCertificateSigningRequest(certificateSigningRequest)
content := "{content}"
certificateSigningRequest.SetContent(&content)
transportKey := "{sampleTransportKey}"
certificateSigningRequest.SetTransportKey(&transportKey)
requestBody.SetConnectorId(nil)
graphClient.Print().Printers().Create().Post(requestBody)
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