Chilkat Online Tools

delphiDll / Microsoft Graph / Register schema

Back to Collection Items

var
http: HCkHttp;
success: Boolean;
json: HCkJsonObject;
resp: HCkHttpResponse;

begin
// This example assumes the Chilkat API to have been previously unlocked.
// See Global Unlock Sample for sample code.

http := CkHttp_Create();

// 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": [
//       ]
//     }
//   ]
// }

json := CkJsonObject_Create();
CkJsonObject_UpdateString(json,'baseType','microsoft.graph.externalItem');
CkJsonObject_UpdateString(json,'properties[0].name','id');
CkJsonObject_UpdateString(json,'properties[0].type','string');
CkJsonObject_UpdateBool(json,'properties[0].isSearchable',False);
CkJsonObject_UpdateBool(json,'properties[0].isRetrievable',True);
CkJsonObject_UpdateBool(json,'properties[0].isQueryable',False);
CkJsonObject_UpdateNewArray(json,'properties[0].labels');
CkJsonObject_UpdateNewArray(json,'properties[0].aliases');
CkJsonObject_UpdateString(json,'properties[1].name','title');
CkJsonObject_UpdateString(json,'properties[1].type','string');
CkJsonObject_UpdateBool(json,'properties[1].isSearchable',True);
CkJsonObject_UpdateBool(json,'properties[1].isRetrievable',True);
CkJsonObject_UpdateBool(json,'properties[1].isQueryable',True);
CkJsonObject_UpdateString(json,'properties[1].labels[0]','title');
CkJsonObject_UpdateNewArray(json,'properties[1].aliases');
CkJsonObject_UpdateString(json,'properties[2].name','extension');
CkJsonObject_UpdateString(json,'properties[2].type','string');
CkJsonObject_UpdateBool(json,'properties[2].isSearchable',True);
CkJsonObject_UpdateBool(json,'properties[2].isRetrievable',True);
CkJsonObject_UpdateBool(json,'properties[2].isQueryable',True);
CkJsonObject_UpdateNewArray(json,'properties[2].labels');
CkJsonObject_UpdateNewArray(json,'properties[2].aliases');
CkJsonObject_UpdateString(json,'properties[3].name','createdBy');
CkJsonObject_UpdateString(json,'properties[3].type','string');
CkJsonObject_UpdateBool(json,'properties[3].isSearchable',True);
CkJsonObject_UpdateBool(json,'properties[3].isRetrievable',True);
CkJsonObject_UpdateBool(json,'properties[3].isQueryable',True);
CkJsonObject_UpdateString(json,'properties[3].labels[0]','createdBy');
CkJsonObject_UpdateNewArray(json,'properties[3].aliases');
CkJsonObject_UpdateString(json,'properties[4].name','createdDateTime');
CkJsonObject_UpdateString(json,'properties[4].type','dateTime');
CkJsonObject_UpdateBool(json,'properties[4].isSearchable',False);
CkJsonObject_UpdateBool(json,'properties[4].isRetrievable',True);
CkJsonObject_UpdateBool(json,'properties[4].isQueryable',True);
CkJsonObject_UpdateString(json,'properties[4].labels[0]','createdDateTime');
CkJsonObject_UpdateNewArray(json,'properties[4].aliases');
CkJsonObject_UpdateString(json,'properties[5].name','lastModifiedBy');
CkJsonObject_UpdateString(json,'properties[5].type','string');
CkJsonObject_UpdateBool(json,'properties[5].isSearchable',False);
CkJsonObject_UpdateBool(json,'properties[5].isRetrievable',True);
CkJsonObject_UpdateBool(json,'properties[5].isQueryable',True);
CkJsonObject_UpdateNewArray(json,'properties[5].labels');
CkJsonObject_UpdateNewArray(json,'properties[5].aliases');
CkJsonObject_UpdateString(json,'properties[6].name','lastModifiedDate');
CkJsonObject_UpdateString(json,'properties[6].type','dateTime');
CkJsonObject_UpdateBool(json,'properties[6].isSearchable',False);
CkJsonObject_UpdateBool(json,'properties[6].isRetrievable',True);
CkJsonObject_UpdateBool(json,'properties[6].isQueryable',True);
CkJsonObject_UpdateString(json,'properties[6].labels[0]','lastModifiedDateTime');
CkJsonObject_UpdateNewArray(json,'properties[6].aliases');
CkJsonObject_UpdateString(json,'properties[7].name','url');
CkJsonObject_UpdateString(json,'properties[7].type','string');
CkJsonObject_UpdateBool(json,'properties[7].isSearchable',False);
CkJsonObject_UpdateBool(json,'properties[7].isRetrievable',True);
CkJsonObject_UpdateBool(json,'properties[7].isQueryable',False);
CkJsonObject_UpdateString(json,'properties[7].labels[0]','url');
CkJsonObject_UpdateNewArray(json,'properties[7].aliases');
CkJsonObject_UpdateString(json,'properties[8].name','description');
CkJsonObject_UpdateString(json,'properties[8].type','string');
CkJsonObject_UpdateBool(json,'properties[8].isSearchable',False);
CkJsonObject_UpdateBool(json,'properties[8].isRetrievable',True);
CkJsonObject_UpdateBool(json,'properties[8].isQueryable',False);
CkJsonObject_UpdateNewArray(json,'properties[8].labels');
CkJsonObject_UpdateNewArray(json,'properties[8].aliases');
CkJsonObject_UpdateString(json,'properties[9].name','authors');
CkJsonObject_UpdateString(json,'properties[9].type','stringCollection');
CkJsonObject_UpdateBool(json,'properties[9].isSearchable',False);
CkJsonObject_UpdateBool(json,'properties[9].isRetrievable',True);
CkJsonObject_UpdateBool(json,'properties[9].isQueryable',False);
CkJsonObject_UpdateString(json,'properties[9].labels[0]','authors');
CkJsonObject_UpdateNewArray(json,'properties[9].aliases');

CkHttp_SetRequestHeader(http,'Content-Type','application/json');
// Adds the "Authorization: Bearer <access_token>" header.
CkHttp_putAuthToken(http,'<access_token>');
CkHttp_SetRequestHeader(http,'prefer','respond-async');

resp := CkHttp_PostJson3(http,'https://graph.microsoft.com/v1.0/external/connections/sampleConnectionId/schema','application/json',json);
if (CkHttp_getLastMethodSuccess(http) = False) then
  begin
    Memo1.Lines.Add(CkHttp__lastErrorText(http));
    Exit;
  end;

Memo1.Lines.Add(IntToStr(CkHttpResponse_getStatusCode(resp)));
Memo1.Lines.Add(CkHttpResponse__bodyStr(resp));
CkHttpResponse_Dispose(resp);

CkHttp_Dispose(http);
CkJsonObject_Dispose(json);

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": [
  ]
}