Forum Discussion
HimanJo
Apr 14, 2021Copper Contributor
Get printerCreateOperation while registering the printer using java msal?
Hello All, I am trying to register a printer in the universal print service using the Java SDK and I have been following this documentation - https://docs.microsoft.com/en-us/graph/api/printer-creat...
baywet
Microsoft
Apr 16, 2021Hi Himan Jo,
Thanks for reaching out.
I'm the main maintainer of the Microsoft Graph Java SDK.
The reason why the SDK is not returning any information as of now is because the create method is described as an action, and actions don't have a return type (search for Parameter Name="bindingParameter" Type="Collection(graph.printer)" in https://graph.microsoft.com/beta/$metadata )
I've let the product team know they should address this issue, either by correcting the documentation and removing the response payload or by using a Function with a return type instead so the code generated in the SDK will have a return type too.
In the meantime and as a workaround, you should be able to use a custom request like this:
final PrinterCreateParameterSet result = new CustomRequest<PrinterCreateParameterSet>("https://graph.microsoft.com/beta/print/printers/create", graphClient, null, PrinterCreateParameterSet.class).post(
PrinterCreateParameterSet
.newBuilder()
.withDisplayName(displayName)
.withManufacturer(manufacturer)
.withModel(model)
.withPhysicalDeviceId(physicalDeviceId)
.withHasPhysicalDevice(hasPhysicalDevice)
.withCertificateSigningRequest(certificateSigningRequest)
.withConnectorId(connectorId)
.build());
Thanks for reaching out.
I'm the main maintainer of the Microsoft Graph Java SDK.
The reason why the SDK is not returning any information as of now is because the create method is described as an action, and actions don't have a return type (search for Parameter Name="bindingParameter" Type="Collection(graph.printer)" in https://graph.microsoft.com/beta/$metadata )
I've let the product team know they should address this issue, either by correcting the documentation and removing the response payload or by using a Function with a return type instead so the code generated in the SDK will have a return type too.
In the meantime and as a workaround, you should be able to use a custom request like this:
final PrinterCreateParameterSet result = new CustomRequest<PrinterCreateParameterSet>("https://graph.microsoft.com/beta/print/printers/create", graphClient, null, PrinterCreateParameterSet.class).post(
PrinterCreateParameterSet
.newBuilder()
.withDisplayName(displayName)
.withManufacturer(manufacturer)
.withModel(model)
.withPhysicalDeviceId(physicalDeviceId)
.withHasPhysicalDevice(hasPhysicalDevice)
.withCertificateSigningRequest(certificateSigningRequest)
.withConnectorId(connectorId)
.build());