创建架构
命名空间:microsoft.graph.externalConnectors
创建新的 架构 对象。
权限
要调用此 API,需要以下权限之一。要了解详细信息,包括如何选择权限的信息,请参阅权限。
| 权限类型 |
权限(从最低特权到最高特权) |
| 委派(工作或学校帐户) |
ExternalConnection.ReadWrite.OwnedBy,ExternalConnection.ReadWrite.All |
| 委派(个人 Microsoft 帐户) |
不适用 |
| 应用程序 |
ExternalConnection.ReadWrite.OwnedBy,ExternalConnection.ReadWrite.All |
HTTP 请求
POST /external/connections/{id}/schema
在请求正文中,提供 架构 对象的 JSON 表示形式。
注册自定义项架构时, 架构 对象 必须 将 baseType 属性设置为 microsoft.graph.externalItem 并且 必须 包含 属性 属性。 properties 对象 必须 至少包含一个属性,最多 128 个属性。
响应
如果成功,此方法会在响应标头中Location返回202 Accepted响应代码和 URL,该 URL 可用于获取操作状态。
示例
示例:异步注册自定义架构
请求
下面展示了示例请求。
POST https://graph.microsoft.com/v1.0/external/connections/contosohr/schema
Content-type: application/json
{
"baseType": "microsoft.graph.externalItem",
"properties": [
{
"name": "ticketTitle",
"type": "String",
"isSearchable": "true",
"isRetrievable": "true",
"labels": [
"title"
]
},
{
"name": "priority",
"type": "String",
"isQueryable": "true",
"isRetrievable": "true",
"isSearchable": "false"
},
{
"name": "assignee",
"type": "String",
"isRetrievable": "true"
}
]
}
GraphServiceClient graphClient = new GraphServiceClient( authProvider );
var schema = new Microsoft.Graph.ExternalConnectors.Schema
{
BaseType = "microsoft.graph.externalItem",
Properties = new List<Microsoft.Graph.ExternalConnectors.Property>()
{
new Microsoft.Graph.ExternalConnectors.Property
{
Name = "ticketTitle",
Type = Microsoft.Graph.ExternalConnectors.PropertyType.String,
IsSearchable = true,
IsRetrievable = true,
Labels = new List<Microsoft.Graph.ExternalConnectors.Label>()
{
Microsoft.Graph.ExternalConnectors.Label.Title
}
},
new Microsoft.Graph.ExternalConnectors.Property
{
Name = "priority",
Type = Microsoft.Graph.ExternalConnectors.PropertyType.String,
IsQueryable = true,
IsRetrievable = true,
IsSearchable = false
},
new Microsoft.Graph.ExternalConnectors.Property
{
Name = "assignee",
Type = Microsoft.Graph.ExternalConnectors.PropertyType.String,
IsRetrievable = true
}
}
};
await graphClient.External.Connections["{externalConnectors.externalConnection-id}"].Schema
.Request()
.AddAsync(schema);
有关如何将 SDK 添加 到项目并 创建 authProvider 实例的 详细信息,请参阅 SDK 文档。
const options = {
authProvider,
};
const client = Client.init(options);
const schema = {
baseType: 'microsoft.graph.externalItem',
properties: [
{
name: 'ticketTitle',
type: 'String',
isSearchable: 'true',
isRetrievable: 'true',
labels: [
'title'
]
},
{
name: 'priority',
type: 'String',
isQueryable: 'true',
isRetrievable: 'true',
isSearchable: 'false'
},
{
name: 'assignee',
type: 'String',
isRetrievable: 'true'
}
]
};
await client.api('/external/connections/contosohr/schema')
.post(schema);
有关如何将 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/schema"]]];
[urlRequest setHTTPMethod:@"POST"];
[urlRequest setValue:@"application/json" forHTTPHeaderField:@"Content-Type"];
MSGraphExternalConnectorsSchema *schema = [[MSGraphExternalConnectorsSchema alloc] init];
[schema setBaseType:@"microsoft.graph.externalItem"];
NSMutableArray *propertiesList = [[NSMutableArray alloc] init];
MSGraphExternalConnectorsProperty *properties = [[MSGraphExternalConnectorsProperty alloc] init];
[properties setName:@"ticketTitle"];
[properties setType: [MSGraphExternalConnectorsPropertyType string]];
[properties setIsSearchable:@"true"];
[properties setIsRetrievable:@"true"];
NSMutableArray *labelsList = [[NSMutableArray alloc] init];
[labelsList addObject: @"title"];
[properties setLabels:labelsList];
[propertiesList addObject: properties];
MSGraphExternalConnectorsProperty *properties = [[MSGraphExternalConnectorsProperty alloc] init];
[properties setName:@"priority"];
[properties setType: [MSGraphExternalConnectorsPropertyType string]];
[properties setIsQueryable:@"true"];
[properties setIsRetrievable:@"true"];
[properties setIsSearchable:@"false"];
[propertiesList addObject: properties];
MSGraphExternalConnectorsProperty *properties = [[MSGraphExternalConnectorsProperty alloc] init];
[properties setName:@"assignee"];
[properties setType: [MSGraphExternalConnectorsPropertyType string]];
[properties setIsRetrievable:@"true"];
[propertiesList addObject: properties];
[schema setProperties:propertiesList];
NSError *error;
NSData *schemaData = [schema getSerializedDataWithError:&error];
[urlRequest setHTTPBody:schemaData];
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();
Schema schema = new Schema();
schema.baseType = "microsoft.graph.externalItem";
LinkedList<Property> propertiesList = new LinkedList<Property>();
Property properties = new Property();
properties.name = "ticketTitle";
properties.type = PropertyType.STRING;
properties.isSearchable = false;
properties.isRetrievable = false;
LinkedList<Label> labelsList = new LinkedList<Label>();
labelsList.add(Label.TITLE);
properties.labels = labelsList;
propertiesList.add(properties);
Property properties1 = new Property();
properties1.name = "priority";
properties1.type = PropertyType.STRING;
properties1.isQueryable = false;
properties1.isRetrievable = false;
properties1.isSearchable = false;
propertiesList.add(properties1);
Property properties2 = new Property();
properties2.name = "assignee";
properties2.type = PropertyType.STRING;
properties2.isRetrievable = false;
propertiesList.add(properties2);
schema.properties = propertiesList;
graphClient.external().connections("contosohr").schema()
.buildRequest()
.post(schema);
有关如何将 SDK 添加 到项目并 创建 authProvider 实例的 详细信息,请参阅 SDK 文档。
//THE GO SDK IS IN PREVIEW. NON-PRODUCTION USE ONLY
graphClient := msgraphsdk.NewGraphServiceClient(requestAdapter)
requestBody := msgraphsdk.New()
requestBody.SetAdditionalData(map[string]interface{}{
"baseType": "microsoft.graph.externalItem",
"properties": []Object {
}
}
externalConnectionId := "externalConnection-id"
graphClient.External().ConnectionsById(&externalConnectionId).Schema().Post(requestBody)
有关如何将 SDK 添加 到项目并 创建 authProvider 实例的 详细信息,请参阅 SDK 文档。
响应
下面展示了示例响应。
HTTP/1.1 202 Accepted
Location: https://graph.microsoft.com/v1.0/external/connections/contosohr/operations/616bfeed-666f-4ce0-8cd9-058939010bfc