Schema erstellen
Artikel
07/18/2022
3 Minuten Lesedauer
3 Mitwirkende
In diesem Artikel
Namespace: microsoft.graph.externalConnectors
Erstellen Sie ein neues Schemaobjekt .
Berechtigungen
Eine der nachfolgenden Berechtigungen ist erforderlich, um diese API aufrufen zu können. Weitere Informationen, unter anderem zur Auswahl von Berechtigungen, finden Sie im Artikel zum Thema Berechtigungen .
Berechtigungstyp
Berechtigungen (von der Berechtigung mit den wenigsten Rechten zu der mit den meisten Rechten)
Delegiert (Geschäfts-, Schul- oder Unikonto)
ExternalConnection.ReadWrite.OwnedBy, ExternalConnection.ReadWrite.All
Delegiert (persönliches Microsoft-Konto)
Nicht zutreffend
Anwendung
ExternalConnection.ReadWrite.OwnedBy, ExternalConnection.ReadWrite.All
HTTP-Anforderung
POST /external/connections/{id}/schema
Geben Sie im Anforderungstext eine JSON-Darstellung eines Schemaobjekts an.
Wenn Sie ein benutzerdefiniertes Elementschema registrieren, muss für das Schemaobjekt die baseType-Eigenschaft festgelegt microsoft.graph.externalItem sein und die Eigenschafteneigenschaft enthalten sein. Das Eigenschaftenobjekt muss mindestens eine Eigenschaft enthalten, maximal 128.
Antwort
Bei erfolgreicher Ausführung gibt die Methode einen 202 Accepted Antwortcode und eine URL im Location Antwortheader zurück, die zum Abrufen des Vorgangsstatus verwendet werden können.
Beispiele
Beispiel: Asynchrones Registrieren eines benutzerdefinierten Schemas
Anforderung
Nachfolgend sehen Sie ein Beispiel der Anforderung.
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);
Ausführliche Informationen zum Hinzufügen des SDK zu Ihrem Projekt und zum Erstellen einer authProvider-Instanz finden Sie in der SDK-Dokumentation .
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);
Ausführliche Informationen zum Hinzufügen des SDK zu Ihrem Projekt und zum Erstellen einer authProvider-Instanz finden Sie in der SDK-Dokumentation .
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];
Ausführliche Informationen zum Hinzufügen des SDK zu Ihrem Projekt und zum Erstellen einer authProvider-Instanz finden Sie in der SDK-Dokumentation .
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);
Ausführliche Informationen zum Hinzufügen des SDK zu Ihrem Projekt und zum Erstellen einer authProvider-Instanz finden Sie in der SDK-Dokumentation .
//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)
Ausführliche Informationen zum Hinzufügen des SDK zu Ihrem Projekt und zum Erstellen einer authProvider-Instanz finden Sie in der SDK-Dokumentation .
Antwort
Nachfolgend sehen Sie ein Beispiel der Antwort.
HTTP/1.1 202 Accepted
Location: https://graph.microsoft.com/v1.0/external/connections/contosohr/operations/616bfeed-666f-4ce0-8cd9-058939010bfc