更新 externalItem
命名空间:microsoft.graph.externalConnectors
更新 externalItem 对象的属性。
权限
要调用此 API,需要以下权限之一。要了解详细信息,包括如何选择权限的信息,请参阅权限。
| 权限类型 |
权限(从最低特权到最高特权) |
| 委派(工作或学校帐户) |
ExternalItem.ReadWrite.OwnedBy、ExternalItem.ReadWrite.All |
| 委派(个人 Microsoft 帐户) |
不支持 |
| Application |
ExternalItem.ReadWrite.OwnedBy、ExternalItem.ReadWrite.All |
HTTP 请求
PATCH /external/connections/{connection-id}/items/{item-id}
路径参数
| 名称 |
说明 |
| Authorization |
Bearer {token}。必需。 |
| Content-Type |
application/json. Required. |
请求正文
在请求正文中,提供应更新的相关字段的值。 现有属性 (排除未包含在请求正文中的对象) 中的属性 properties ,将保留其以前的值,或根据对其他属性值的更改重新计算。 为了获得最佳性能,请勿加入尚未更改的现有值。 可更新以下属性。
更新 acl 集合
如果该 acl 属性包含在更新请求中,则现有 ACL 集合会被请求中包含的集合覆盖。
更新 properties 对象
如果该 properties 属性包含在更新请求中,则会用请求中包含的值覆盖现有属性包。
响应
如果成功,此方法在响应正文中返回 200 OK 响应代码和更新的 externalItem 对象。
示例
请求
PATCH https://graph.microsoft.com/v1.0/external/connections/contosohr/items/TSP228082938
Content-Type: application/json
{
"acl": [
{
"type": "everyone",
"value": "67a141d8-cf4e-4528-ba07-bed21bfacd2d",
"accessType": "grant"
}
]
}
GraphServiceClient graphClient = new GraphServiceClient( authProvider );
var externalItem = new Microsoft.Graph.ExternalConnectors.ExternalItem
{
Acl = new List<Microsoft.Graph.ExternalConnectors.Acl>()
{
new Microsoft.Graph.ExternalConnectors.Acl
{
Type = Microsoft.Graph.ExternalConnectors.AclType.Everyone,
Value = "67a141d8-cf4e-4528-ba07-bed21bfacd2d",
AccessType = Microsoft.Graph.ExternalConnectors.AccessType.Grant
}
}
};
await graphClient.External.Connections["{externalConnectors.externalConnection-id}"].Items["{externalConnectors.externalItem-id}"]
.Request()
.UpdateAsync(externalItem);
有关如何将 SDK 添加 到项目并 创建 authProvider 实例的 详细信息,请参阅 SDK 文档。
const options = {
authProvider,
};
const client = Client.init(options);
const externalItem = {
acl: [
{
type: 'everyone',
value: '67a141d8-cf4e-4528-ba07-bed21bfacd2d',
accessType: 'grant'
}
]
};
await client.api('/external/connections/contosohr/items/TSP228082938')
.update(externalItem);
有关如何将 SDK 添加 到项目并 创建 authProvider 实例的 详细信息,请参阅 SDK 文档。
MSHTTPClient *httpClient = [MSClientFactory createHTTPClientWithAuthenticationProvider:authenticationProvider];
NSString *MSGraphBaseURL = @"https://graph.microsoft.com/v1.0/";
NSMutableURLRequest *urlRequest = [NSMutableURLRequest requestWithURL:[NSURL URLWithString:[MSGraphBaseURL stringByAppendingString:@"/external/connections/contosohr/items/TSP228082938"]]];
[urlRequest setHTTPMethod:@"PATCH"];
[urlRequest setValue:@"application/json" forHTTPHeaderField:@"Content-Type"];
MSGraphExternalConnectorsExternalItem *externalItem = [[MSGraphExternalConnectorsExternalItem alloc] init];
NSMutableArray *aclList = [[NSMutableArray alloc] init];
MSGraphExternalConnectorsAcl *acl = [[MSGraphExternalConnectorsAcl alloc] init];
[acl setType: [MSGraphExternalConnectorsAclType everyone]];
[acl setValue:@"67a141d8-cf4e-4528-ba07-bed21bfacd2d"];
[acl setAccessType: [MSGraphExternalConnectorsAccessType grant]];
[aclList addObject: acl];
[externalItem setAcl:aclList];
NSError *error;
NSData *externalItemData = [externalItem getSerializedDataWithError:&error];
[urlRequest setHTTPBody:externalItemData];
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();
ExternalItem externalItem = new ExternalItem();
LinkedList<Acl> aclList = new LinkedList<Acl>();
Acl acl = new Acl();
acl.type = AclType.EVERYONE;
acl.value = "67a141d8-cf4e-4528-ba07-bed21bfacd2d";
acl.accessType = AccessType.GRANT;
aclList.add(acl);
externalItem.acl = aclList;
graphClient.external().connections("contosohr").items("TSP228082938")
.buildRequest()
.patch(externalItem);
有关如何将 SDK 添加 到项目并 创建 authProvider 实例的 详细信息,请参阅 SDK 文档。
//THE GO SDK IS IN PREVIEW. NON-PRODUCTION USE ONLY
graphClient := msgraphsdk.NewGraphServiceClient(requestAdapter)
requestBody := msgraphsdk.NewExternalItem()
requestBody.SetAcl( []Acl {
msgraphsdk.NewAcl(),
type := "everyone"
SetType(&type)
value := "67a141d8-cf4e-4528-ba07-bed21bfacd2d"
SetValue(&value)
accessType := "grant"
SetAccessType(&accessType)
}
externalConnectionId := "externalConnection-id"
externalItemId := "externalItem-id"
graphClient.External().ConnectionsById(&externalConnectionId).ItemsById(&externalItemId).Patch(requestBody)
有关如何将 SDK 添加 到项目并 创建 authProvider 实例的 详细信息,请参阅 SDK 文档。
Import-Module Microsoft.Graph.Search
$params = @{
Acl = @(
@{
Type = "everyone"
Value = "67a141d8-cf4e-4528-ba07-bed21bfacd2d"
AccessType = "grant"
}
)
}
Update-MgExternalConnectionItem -ExternalConnectionId $externalConnectionId -ExternalItemId $externalItemId -BodyParameter $params
有关如何将 SDK 添加 到项目并 创建 authProvider 实例的 详细信息,请参阅 SDK 文档。
响应
下面展示了示例响应。
HTTP/1.1 200 OK
Content-type: application/json
{
"id": "TSP228082938",
"acl": [
{
"type": "everyone",
"value": "67a141d8-cf4e-4528-ba07-bed21bfacd2d",
"accessType": "grant"
}
],
"properties": {
"title": "Error in the payment gateway",
"priority": 1,
"assignee": "john@contoso.com"
},
"content": {
"@odata.type": "microsoft.graph.externalConnectors.externalItemContent",
"value": "<h1>Error in payment gateway</h1><p>Error details...</p>",
"type": "html"
}
}