更新 printConnector
命名空间:microsoft.graph
更新 printConnector 对象 的属性。
权限
要调用此 API,需要以下权限之一。要了解详细信息,包括如何选择权限的信息,请参阅权限。
若要使用通用打印服务,除了下表中列出的权限之外,用户或应用的租户还必须具有活动的通用打印订阅。 登录的用户必须是打印机 管理员。
| 权限类型 |
权限(从最低特权到最高特权) |
| 委派(工作或学校帐户) |
PrintConnector.ReadWrite.All |
| 委派(个人 Microsoft 帐户) |
不支持。 |
| 应用程序 |
不支持。 |
HTTP 请求
PATCH /print/connectors/{printConnectorId}
| 名称 |
说明 |
| Authorization |
Bearer {token}。必需。 |
| Content-Type |
application/json. Required. |
请求正文
在请求正文中,提供应更新的相关字段的值。 请求正文中不包括的现有属性将保留其以前的值,或根据对其他属性值的更改重新计算。 为了获得最佳性能,请勿加入尚未更改的现有值。
响应
如果成功,此方法在响应正文中返回 响应代码和更新的 200 OK printConnector 对象。
示例
请求
PATCH https://graph.microsoft.com/v1.0/print/connectors/{printConnectorId}
Content-Type: application/json
{
"displayName": "ConnectorName",
"fullyQualifiedDomainName": "CONNECTOR-MACHINE",
"operatingSystem": "Microsoft Windows 10 Enterprise Insider Preview | 10.0.19555",
"appVersion": "0.19.7338.23496",
"location": {
"latitude": 1.1,
"longitude": 2.2,
"altitudeInMeters": 3
}
}
GraphServiceClient graphClient = new GraphServiceClient( authProvider );
var printConnector = new PrintConnector
{
DisplayName = "ConnectorName",
FullyQualifiedDomainName = "CONNECTOR-MACHINE",
OperatingSystem = "Microsoft Windows 10 Enterprise Insider Preview | 10.0.19555",
AppVersion = "0.19.7338.23496",
Location = new PrinterLocation
{
Latitude = 1.1,
Longitude = 2.2,
AltitudeInMeters = 3
}
};
await graphClient.Print.Connectors["{printConnector-id}"]
.Request()
.UpdateAsync(printConnector);
有关如何将 SDK 添加 到项目并 创建 authProvider 实例的 详细信息,请参阅 SDK 文档。
const options = {
authProvider,
};
const client = Client.init(options);
const printConnector = {
displayName: 'ConnectorName',
fullyQualifiedDomainName: 'CONNECTOR-MACHINE',
operatingSystem: 'Microsoft Windows 10 Enterprise Insider Preview | 10.0.19555',
appVersion: '0.19.7338.23496',
location: {
latitude: 1.1,
longitude: 2.2,
altitudeInMeters: 3
}
};
await client.api('/print/connectors/{printConnectorId}')
.update(printConnector);
有关如何将 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/connectors/{printConnectorId}"]]];
[urlRequest setHTTPMethod:@"PATCH"];
[urlRequest setValue:@"application/json" forHTTPHeaderField:@"Content-Type"];
MSGraphPrintConnector *printConnector = [[MSGraphPrintConnector alloc] init];
[printConnector setDisplayName:@"ConnectorName"];
[printConnector setFullyQualifiedDomainName:@"CONNECTOR-MACHINE"];
[printConnector setOperatingSystem:@"Microsoft Windows 10 Enterprise Insider Preview | 10.0.19555"];
[printConnector setAppVersion:@"0.19.7338.23496"];
MSGraphPrinterLocation *location = [[MSGraphPrinterLocation alloc] init];
[location setLatitude: 1.1];
[location setLongitude: 2.2];
[location setAltitudeInMeters: 3];
[printConnector setLocation:location];
NSError *error;
NSData *printConnectorData = [printConnector getSerializedDataWithError:&error];
[urlRequest setHTTPBody:printConnectorData];
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();
PrintConnector printConnector = new PrintConnector();
printConnector.displayName = "ConnectorName";
printConnector.fullyQualifiedDomainName = "CONNECTOR-MACHINE";
printConnector.operatingSystem = "Microsoft Windows 10 Enterprise Insider Preview | 10.0.19555";
printConnector.appVersion = "0.19.7338.23496";
PrinterLocation location = new PrinterLocation();
location.latitude = 1.1d;
location.longitude = 2.2d;
location.altitudeInMeters = 3;
printConnector.location = location;
graphClient.print().connectors("{printConnectorId}")
.buildRequest()
.patch(printConnector);
有关如何将 SDK 添加 到项目并 创建 authProvider 实例的 详细信息,请参阅 SDK 文档。
//THE GO SDK IS IN PREVIEW. NON-PRODUCTION USE ONLY
graphClient := msgraphsdk.NewGraphServiceClient(requestAdapter)
requestBody := msgraphsdk.NewPrintConnector()
displayName := "ConnectorName"
requestBody.SetDisplayName(&displayName)
fullyQualifiedDomainName := "CONNECTOR-MACHINE"
requestBody.SetFullyQualifiedDomainName(&fullyQualifiedDomainName)
operatingSystem := "Microsoft Windows 10 Enterprise Insider Preview | 10.0.19555"
requestBody.SetOperatingSystem(&operatingSystem)
appVersion := "0.19.7338.23496"
requestBody.SetAppVersion(&appVersion)
location := msgraphsdk.NewPrinterLocation()
requestBody.SetLocation(location)
latitude := float64(1.1)
location.SetLatitude(&latitude)
longitude := float64(2.2)
location.SetLongitude(&longitude)
altitudeInMeters := int32(3)
location.SetAltitudeInMeters(&altitudeInMeters)
printConnectorId := "printConnector-id"
graphClient.Print().ConnectorsById(&printConnectorId).Patch(requestBody)
有关如何将 SDK 添加 到项目并 创建 authProvider 实例的 详细信息,请参阅 SDK 文档。
Import-Module Microsoft.Graph.Devices.CloudPrint
$params = @{
DisplayName = "ConnectorName"
FullyQualifiedDomainName = "CONNECTOR-MACHINE"
OperatingSystem = "Microsoft Windows 10 Enterprise Insider Preview | 10.0.19555"
AppVersion = "0.19.7338.23496"
Location = @{
Latitude = 1.1
Longitude = 2.2
AltitudeInMeters = 3
}
}
Update-MgPrintConnector -PrintConnectorId $printConnectorId -BodyParameter $params
有关如何将 SDK 添加 到项目并 创建 authProvider 实例的 详细信息,请参阅 SDK 文档。
响应
注意: 为了提高可读性,可能缩短了此处显示的响应对象。
HTTP/1.1 200 OK
Content-Type: application/json
{
"@odata.context": "https://graph.microsoft.com/v1.0/$metadata#print/connectors/$entity",
"id": "9953d245-3f6e-418c-a438-67f50e69a430",
"displayName": "ConnectorName",
"fullyQualifiedDomainName": "CONNECTOR-MACHINE",
"operatingSystem": "Microsoft Windows 10 Enterprise Insider Preview | 10.0.19555",
"appVersion": "0.19.7338.23496",
"registeredDateTime": "2020-02-04T00:00:00.0000000Z",
"location": {
"latitude": 1.1,
"longitude": 2.2,
"altitudeInMeters": 3,
"streetAddress": "One Microsoft Way",
"subUnit": [
"Main Plaza",
"Unit 400"
],
"city": "Redmond",
"postalCode": "98052",
"countryOrRegion": "USA",
"site": "Puget Sound",
"building": "Studio E",
"floor": "1",
"floorDescription": "First Floor",
"roomName": "1234",
"roomDescription": "First floor copy room",
"organization": [
"C+AI",
"Microsoft Graph"
],
"subdivision": [
"King County",
"Red West"
],
"stateOrProvince": "Washington"
}
}