Objective-C / Microsoft Graph / Register schema
Back to Collection Items
#import <CkoHttp.h>
#import <CkoJsonObject.h>
#import <CkoHttpResponse.h>
// This example assumes the Chilkat API to have been previously unlocked.
// See Global Unlock Sample for sample code.
CkoHttp *http = [[CkoHttp alloc] init];
BOOL success;
// Use this online tool to generate code from sample JSON: Generate Code to Create JSON
// The following JSON is sent in the request body.
// {
// "baseType": "microsoft.graph.externalItem",
// "properties": [
// {
// "name": "id",
// "type": "string",
// "isSearchable": false,
// "isRetrievable": true,
// "isQueryable": false,
// "labels": [
// ],
// "aliases": [
// ]
// },
// {
// "name": "title",
// "type": "string",
// "isSearchable": true,
// "isRetrievable": true,
// "isQueryable": true,
// "labels": [
// "title"
// ],
// "aliases": [
// ]
// },
// {
// "name": "extension",
// "type": "string",
// "isSearchable": true,
// "isRetrievable": true,
// "isQueryable": true,
// "labels": [
// ],
// "aliases": [
// ]
// },
// {
// "name": "createdBy",
// "type": "string",
// "isSearchable": true,
// "isRetrievable": true,
// "isQueryable": true,
// "labels": [
// "createdBy"
// ],
// "aliases": [
// ]
// },
// {
// "name": "createdDateTime",
// "type": "dateTime",
// "isSearchable": false,
// "isRetrievable": true,
// "isQueryable": true,
// "labels": [
// "createdDateTime"
// ],
// "aliases": [
// ]
// },
// {
// "name": "lastModifiedBy",
// "type": "string",
// "isSearchable": false,
// "isRetrievable": true,
// "isQueryable": true,
// "labels": [
// ],
// "aliases": [
// ]
// },
// {
// "name": "lastModifiedDate",
// "type": "dateTime",
// "isSearchable": false,
// "isRetrievable": true,
// "isQueryable": true,
// "labels": [
// "lastModifiedDateTime"
// ],
// "aliases": [
// ]
// },
// {
// "name": "url",
// "type": "string",
// "isSearchable": false,
// "isRetrievable": true,
// "isQueryable": false,
// "labels": [
// "url"
// ],
// "aliases": [
// ]
// },
// {
// "name": "description",
// "type": "string",
// "isSearchable": false,
// "isRetrievable": true,
// "isQueryable": false,
// "labels": [
// ],
// "aliases": [
// ]
// },
// {
// "name": "authors",
// "type": "stringCollection",
// "isSearchable": false,
// "isRetrievable": true,
// "isQueryable": false,
// "labels": [
// "authors"
// ],
// "aliases": [
// ]
// }
// ]
// }
CkoJsonObject *json = [[CkoJsonObject alloc] init];
[json UpdateString: @"baseType" value: @"microsoft.graph.externalItem"];
[json UpdateString: @"properties[0].name" value: @"id"];
[json UpdateString: @"properties[0].type" value: @"string"];
[json UpdateBool: @"properties[0].isSearchable" value: NO];
[json UpdateBool: @"properties[0].isRetrievable" value: YES];
[json UpdateBool: @"properties[0].isQueryable" value: NO];
[json UpdateNewArray: @"properties[0].labels"];
[json UpdateNewArray: @"properties[0].aliases"];
[json UpdateString: @"properties[1].name" value: @"title"];
[json UpdateString: @"properties[1].type" value: @"string"];
[json UpdateBool: @"properties[1].isSearchable" value: YES];
[json UpdateBool: @"properties[1].isRetrievable" value: YES];
[json UpdateBool: @"properties[1].isQueryable" value: YES];
[json UpdateString: @"properties[1].labels[0]" value: @"title"];
[json UpdateNewArray: @"properties[1].aliases"];
[json UpdateString: @"properties[2].name" value: @"extension"];
[json UpdateString: @"properties[2].type" value: @"string"];
[json UpdateBool: @"properties[2].isSearchable" value: YES];
[json UpdateBool: @"properties[2].isRetrievable" value: YES];
[json UpdateBool: @"properties[2].isQueryable" value: YES];
[json UpdateNewArray: @"properties[2].labels"];
[json UpdateNewArray: @"properties[2].aliases"];
[json UpdateString: @"properties[3].name" value: @"createdBy"];
[json UpdateString: @"properties[3].type" value: @"string"];
[json UpdateBool: @"properties[3].isSearchable" value: YES];
[json UpdateBool: @"properties[3].isRetrievable" value: YES];
[json UpdateBool: @"properties[3].isQueryable" value: YES];
[json UpdateString: @"properties[3].labels[0]" value: @"createdBy"];
[json UpdateNewArray: @"properties[3].aliases"];
[json UpdateString: @"properties[4].name" value: @"createdDateTime"];
[json UpdateString: @"properties[4].type" value: @"dateTime"];
[json UpdateBool: @"properties[4].isSearchable" value: NO];
[json UpdateBool: @"properties[4].isRetrievable" value: YES];
[json UpdateBool: @"properties[4].isQueryable" value: YES];
[json UpdateString: @"properties[4].labels[0]" value: @"createdDateTime"];
[json UpdateNewArray: @"properties[4].aliases"];
[json UpdateString: @"properties[5].name" value: @"lastModifiedBy"];
[json UpdateString: @"properties[5].type" value: @"string"];
[json UpdateBool: @"properties[5].isSearchable" value: NO];
[json UpdateBool: @"properties[5].isRetrievable" value: YES];
[json UpdateBool: @"properties[5].isQueryable" value: YES];
[json UpdateNewArray: @"properties[5].labels"];
[json UpdateNewArray: @"properties[5].aliases"];
[json UpdateString: @"properties[6].name" value: @"lastModifiedDate"];
[json UpdateString: @"properties[6].type" value: @"dateTime"];
[json UpdateBool: @"properties[6].isSearchable" value: NO];
[json UpdateBool: @"properties[6].isRetrievable" value: YES];
[json UpdateBool: @"properties[6].isQueryable" value: YES];
[json UpdateString: @"properties[6].labels[0]" value: @"lastModifiedDateTime"];
[json UpdateNewArray: @"properties[6].aliases"];
[json UpdateString: @"properties[7].name" value: @"url"];
[json UpdateString: @"properties[7].type" value: @"string"];
[json UpdateBool: @"properties[7].isSearchable" value: NO];
[json UpdateBool: @"properties[7].isRetrievable" value: YES];
[json UpdateBool: @"properties[7].isQueryable" value: NO];
[json UpdateString: @"properties[7].labels[0]" value: @"url"];
[json UpdateNewArray: @"properties[7].aliases"];
[json UpdateString: @"properties[8].name" value: @"description"];
[json UpdateString: @"properties[8].type" value: @"string"];
[json UpdateBool: @"properties[8].isSearchable" value: NO];
[json UpdateBool: @"properties[8].isRetrievable" value: YES];
[json UpdateBool: @"properties[8].isQueryable" value: NO];
[json UpdateNewArray: @"properties[8].labels"];
[json UpdateNewArray: @"properties[8].aliases"];
[json UpdateString: @"properties[9].name" value: @"authors"];
[json UpdateString: @"properties[9].type" value: @"stringCollection"];
[json UpdateBool: @"properties[9].isSearchable" value: NO];
[json UpdateBool: @"properties[9].isRetrievable" value: YES];
[json UpdateBool: @"properties[9].isQueryable" value: NO];
[json UpdateString: @"properties[9].labels[0]" value: @"authors"];
[json UpdateNewArray: @"properties[9].aliases"];
[http SetRequestHeader: @"Content-Type" value: @"application/json"];
// Adds the "Authorization: Bearer <access_token>" header.
http.AuthToken = @"<access_token>";
[http SetRequestHeader: @"prefer" value: @"respond-async"];
CkoHttpResponse *resp = [http PostJson3: @"https://graph.microsoft.com/v1.0/external/connections/sampleConnectionId/schema" contentType: @"application/json" json: json];
if (http.LastMethodSuccess == NO) {
NSLog(@"%@",http.LastErrorText);
return;
}
NSLog(@"%d",[resp.StatusCode intValue]);
NSLog(@"%@",resp.BodyStr);
Curl Command
curl -X POST
-H "Authorization: Bearer <access_token>"
-H "Content-Type: application/json"
-H "prefer: respond-async"
-d '{
"baseType": "microsoft.graph.externalItem",
"properties": [
{
"name": "id",
"type": "string",
"isSearchable": false,
"isRetrievable": true,
"isQueryable": false,
"labels": [],
"aliases": []
},
{
"name": "title",
"type": "string",
"isSearchable": true,
"isRetrievable": true,
"isQueryable": true,
"labels": [
"title"
],
"aliases": []
},
{
"name": "extension",
"type": "string",
"isSearchable": true,
"isRetrievable": true,
"isQueryable": true,
"labels": [],
"aliases": []
},
{
"name": "createdBy",
"type": "string",
"isSearchable": true,
"isRetrievable": true,
"isQueryable": true,
"labels": [
"createdBy"
],
"aliases": []
},
{
"name": "createdDateTime",
"type": "dateTime",
"isSearchable": false,
"isRetrievable": true,
"isQueryable": true,
"labels": [
"createdDateTime"
],
"aliases": []
},
{
"name": "lastModifiedBy",
"type": "string",
"isSearchable": false,
"isRetrievable": true,
"isQueryable": true,
"labels": [],
"aliases": []
},
{
"name": "lastModifiedDate",
"type": "dateTime",
"isSearchable": false,
"isRetrievable": true,
"isQueryable": true,
"labels": [
"lastModifiedDateTime"
],
"aliases": []
},
{
"name": "url",
"type": "string",
"isSearchable": false,
"isRetrievable": true,
"isQueryable": false,
"labels": [
"url"
],
"aliases": []
},
{
"name": "description",
"type": "string",
"isSearchable": false,
"isRetrievable": true,
"isQueryable": false,
"labels": [],
"aliases": []
},
{
"name": "authors",
"type": "stringCollection",
"isSearchable": false,
"isRetrievable": true,
"isQueryable": false,
"labels": [
"authors"
],
"aliases": []
}
]
}'
https://graph.microsoft.com/v1.0/external/connections/sampleConnectionId/schema
Postman Collection Item JSON
{
"name": "Register schema",
"event": [
{
"listen": "test",
"script": {
"exec": [
"postman.setEnvironmentVariable(\"OperationUrl\", pm.response.headers.get(\"Location\"));"
],
"type": "text/javascript"
}
}
],
"request": {
"method": "POST",
"header": [
{
"key": "Content-Type",
"name": "Content-Type",
"type": "text",
"value": "application/json"
},
{
"key": "prefer",
"type": "text",
"value": "respond-async"
}
],
"body": {
"mode": "raw",
"raw": "{\r\n \"baseType\": \"microsoft.graph.externalItem\",\r\n \"properties\": [\r\n {\r\n \"name\": \"id\",\r\n \"type\": \"string\",\r\n \"isSearchable\": false,\r\n \"isRetrievable\": true,\r\n \"isQueryable\": false,\r\n \"labels\": [],\r\n \"aliases\": []\r\n },\r\n {\r\n \"name\": \"title\",\r\n \"type\": \"string\",\r\n \"isSearchable\": true,\r\n \"isRetrievable\": true,\r\n \"isQueryable\": true,\r\n \"labels\": [\r\n \"title\"\r\n ],\r\n \"aliases\": []\r\n },\r\n {\r\n \"name\": \"extension\",\r\n \"type\": \"string\",\r\n \"isSearchable\": true,\r\n \"isRetrievable\": true,\r\n \"isQueryable\": true,\r\n \"labels\": [],\r\n \"aliases\": []\r\n },\r\n {\r\n \"name\": \"createdBy\",\r\n \"type\": \"string\",\r\n \"isSearchable\": true,\r\n \"isRetrievable\": true,\r\n \"isQueryable\": true,\r\n \"labels\": [\r\n \"createdBy\"\r\n ],\r\n \"aliases\": []\r\n },\r\n {\r\n \"name\": \"createdDateTime\",\r\n \"type\": \"dateTime\",\r\n \"isSearchable\": false,\r\n \"isRetrievable\": true,\r\n \"isQueryable\": true,\r\n \"labels\": [\r\n \"createdDateTime\"\r\n ],\r\n \"aliases\": []\r\n },\r\n {\r\n \"name\": \"lastModifiedBy\",\r\n \"type\": \"string\",\r\n \"isSearchable\": false,\r\n \"isRetrievable\": true,\r\n \"isQueryable\": true,\r\n \"labels\": [],\r\n \"aliases\": []\r\n },\r\n {\r\n \"name\": \"lastModifiedDate\",\r\n \"type\": \"dateTime\",\r\n \"isSearchable\": false,\r\n \"isRetrievable\": true,\r\n \"isQueryable\": true,\r\n \"labels\": [\r\n \"lastModifiedDateTime\"\r\n ],\r\n \"aliases\": []\r\n },\r\n {\r\n \"name\": \"url\",\r\n \"type\": \"string\",\r\n \"isSearchable\": false,\r\n \"isRetrievable\": true,\r\n \"isQueryable\": false,\r\n \"labels\": [\r\n \"url\"\r\n ],\r\n \"aliases\": []\r\n },\r\n {\r\n \"name\": \"description\",\r\n \"type\": \"string\",\r\n \"isSearchable\": false,\r\n \"isRetrievable\": true,\r\n \"isQueryable\": false,\r\n \"labels\": [],\r\n \"aliases\": []\r\n },\r\n {\r\n \"name\": \"authors\",\r\n \"type\": \"stringCollection\",\r\n \"isSearchable\": false,\r\n \"isRetrievable\": true,\r\n \"isQueryable\": false,\r\n \"labels\": [\r\n \"authors\"\r\n ],\r\n \"aliases\": []\r\n }\r\n ]\r\n}"
},
"url": {
"raw": "https://graph.microsoft.com/v1.0/external/connections/sampleConnectionId/schema",
"protocol": "https",
"host": [
"graph",
"microsoft",
"com"
],
"path": [
"v1.0",
"external",
"connections",
"sampleConnectionId",
"schema"
]
}
},
"response": [
]
}