Create schema
Article
03/02/2023
9 contributors
Feedback
In this article
Namespace: microsoft.graph.externalConnectors
Create a new schema object.
Permissions
One of the following permissions is required to call this API. To learn more, including how to choose permissions, see Permissions .
Permission type
Permissions (from least to most privileged)
Delegated (work or school account)
ExternalConnection.ReadWrite.OwnedBy, ExternalConnection.ReadWrite.All
Delegated (personal Microsoft account)
Not applicable
Application
ExternalConnection.ReadWrite.OwnedBy, ExternalConnection.ReadWrite.All
HTTP request
POST /external/connections/{id}/schema
In the request body, supply a JSON representation of a schema object.
When you register a custom item schema, the schema object must have the baseType property set to microsoft.graph.externalItem
and must contain the properties property. The properties object must contain at least one property, up to a maximum of 128.
Response
If successful, this method returns a 202 Accepted
response code and a URL in the Location
response header that can be used to get the operation status .
Examples
Example: Register custom schema asynchronously
Request
The following is an example of the request.
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"
}
]
}
// Code snippets are only available for the latest version. Current version is 5.x
var graphClient = new GraphServiceClient(requestAdapter);
var requestBody = new Microsoft.Graph.External.Connections.Item.Schema.SchemaPostRequestBody
{
AdditionalData = new Dictionary<string, object>
{
{
"baseType" , "microsoft.graph.externalItem"
},
{
"properties" , new List<>
{
new
{
Name = "ticketTitle",
Type = "String",
IsSearchable = "true",
IsRetrievable = "true",
Labels = new List<string>
{
"title",
},
},
new
{
Name = "priority",
Type = "String",
IsQueryable = "true",
IsRetrievable = "true",
IsSearchable = "false",
},
new
{
Name = "assignee",
Type = "String",
IsRetrievable = "true",
},
}
},
},
};
await graphClient.External.Connections["{externalConnection-id}"].Schema.PostAsync(requestBody);
For details about how to add the SDK to your project and create an authProvider instance, see the SDK documentation .
import (
"context"
msgraphsdk "github.com/microsoftgraph/msgraph-sdk-go"
graphmodels "github.com/microsoftgraph/msgraph-sdk-go/External/Connections/Item/Schema"
//other-imports
)
graphClient := msgraphsdk.NewGraphServiceClientWithCredentials(cred, scopes)
requestBody := graphmodels.NewSchemaPostRequestBody()
additionalData := map[string]interface{}{
"baseType" : "microsoft.graph.externalItem",
:= graphmodels.New()
name := "ticketTitle"
.SetName(&name)
type := "String"
.SetType(&type)
isSearchable := "true"
.SetIsSearchable(&isSearchable)
isRetrievable := "true"
.SetIsRetrievable(&isRetrievable)
labels := []string {
"title",
}
.SetLabels(labels)
:= graphmodels.New()
name := "priority"
.SetName(&name)
type := "String"
.SetType(&type)
isQueryable := "true"
.SetIsQueryable(&isQueryable)
isRetrievable := "true"
.SetIsRetrievable(&isRetrievable)
isSearchable := "false"
.SetIsSearchable(&isSearchable)
:= graphmodels.New()
name := "assignee"
.SetName(&name)
type := "String"
.SetType(&type)
isRetrievable := "true"
.SetIsRetrievable(&isRetrievable)
properties := []graphmodels.Objectable {
,
,
,
}
}
requestBody.SetAdditionalData(additionalData)
graphClient.External().Connections().ByConnectionId("externalConnection-id").Schema().Post(context.Background(), requestBody, nil)
For details about how to add the SDK to your project and create an authProvider instance, see the SDK documentation .
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);
For details about how to add the SDK to your project and create an authProvider instance, see the SDK documentation .
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);
For details about how to add the SDK to your project and create an authProvider instance, see the SDK documentation .
<?php
// THIS SNIPPET IS A PREVIEW FOR THE KIOTA BASED SDK. NON-PRODUCTION USE ONLY
$graphServiceClient = new GraphServiceClient($requestAdapter);
$requestBody = new SchemaPostRequestBody();
$additionalData = [
'baseType' => 'microsoft.graph.externalItem',
'properties' => $properties1 = new ();
$ properties1->setName('ticketTitle');
$ properties1->setType('String');
$ properties1->setIsSearchable('true');
$ properties1->setIsRetrievable('true');
$properties1->setLabels(['title', ]);
$propertiesArray []= $properties1;
$properties2 = new ();
$ properties2->setName('priority');
$ properties2->setType('String');
$ properties2->setIsQueryable('true');
$ properties2->setIsRetrievable('true');
$ properties2->setIsSearchable('false');
$propertiesArray []= $properties2;
$properties3 = new ();
$ properties3->setName('assignee');
$ properties3->setType('String');
$ properties3->setIsRetrievable('true');
$propertiesArray []= $properties3;
$requestBody->setProperties($propertiesArray);
];
$requestBody->setAdditionalData($additionalData);
$graphServiceClient->external()->connections()->byConnectionId('externalConnection-id')->schema()->post($requestBody);
For details about how to add the SDK to your project and create an authProvider instance, see the SDK documentation .
Response
The following is an example of the response.
HTTP/1.1 202 Accepted
Location: https://graph.microsoft.com/v1.0/external/connections/contosohr/operations/616bfeed-666f-4ce0-8cd9-058939010bfc