Chilkat Online Tools

autoit / Microsoft Graph / Register schema

Back to Collection Items

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

$oHttp = ObjCreate("Chilkat_9_5_0.Http")
Local $bSuccess

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

$oJson = ObjCreate("Chilkat_9_5_0.JsonObject")
$oJson.UpdateString("baseType","microsoft.graph.externalItem")
$oJson.UpdateString("properties[0].name","id")
$oJson.UpdateString("properties[0].type","string")
$oJson.UpdateBool("properties[0].isSearchable",False)
$oJson.UpdateBool("properties[0].isRetrievable",True)
$oJson.UpdateBool("properties[0].isQueryable",False)
$oJson.UpdateNewArray("properties[0].labels")
$oJson.UpdateNewArray("properties[0].aliases")
$oJson.UpdateString("properties[1].name","title")
$oJson.UpdateString("properties[1].type","string")
$oJson.UpdateBool("properties[1].isSearchable",True)
$oJson.UpdateBool("properties[1].isRetrievable",True)
$oJson.UpdateBool("properties[1].isQueryable",True)
$oJson.UpdateString("properties[1].labels[0]","title")
$oJson.UpdateNewArray("properties[1].aliases")
$oJson.UpdateString("properties[2].name","extension")
$oJson.UpdateString("properties[2].type","string")
$oJson.UpdateBool("properties[2].isSearchable",True)
$oJson.UpdateBool("properties[2].isRetrievable",True)
$oJson.UpdateBool("properties[2].isQueryable",True)
$oJson.UpdateNewArray("properties[2].labels")
$oJson.UpdateNewArray("properties[2].aliases")
$oJson.UpdateString("properties[3].name","createdBy")
$oJson.UpdateString("properties[3].type","string")
$oJson.UpdateBool("properties[3].isSearchable",True)
$oJson.UpdateBool("properties[3].isRetrievable",True)
$oJson.UpdateBool("properties[3].isQueryable",True)
$oJson.UpdateString("properties[3].labels[0]","createdBy")
$oJson.UpdateNewArray("properties[3].aliases")
$oJson.UpdateString("properties[4].name","createdDateTime")
$oJson.UpdateString("properties[4].type","dateTime")
$oJson.UpdateBool("properties[4].isSearchable",False)
$oJson.UpdateBool("properties[4].isRetrievable",True)
$oJson.UpdateBool("properties[4].isQueryable",True)
$oJson.UpdateString("properties[4].labels[0]","createdDateTime")
$oJson.UpdateNewArray("properties[4].aliases")
$oJson.UpdateString("properties[5].name","lastModifiedBy")
$oJson.UpdateString("properties[5].type","string")
$oJson.UpdateBool("properties[5].isSearchable",False)
$oJson.UpdateBool("properties[5].isRetrievable",True)
$oJson.UpdateBool("properties[5].isQueryable",True)
$oJson.UpdateNewArray("properties[5].labels")
$oJson.UpdateNewArray("properties[5].aliases")
$oJson.UpdateString("properties[6].name","lastModifiedDate")
$oJson.UpdateString("properties[6].type","dateTime")
$oJson.UpdateBool("properties[6].isSearchable",False)
$oJson.UpdateBool("properties[6].isRetrievable",True)
$oJson.UpdateBool("properties[6].isQueryable",True)
$oJson.UpdateString("properties[6].labels[0]","lastModifiedDateTime")
$oJson.UpdateNewArray("properties[6].aliases")
$oJson.UpdateString("properties[7].name","url")
$oJson.UpdateString("properties[7].type","string")
$oJson.UpdateBool("properties[7].isSearchable",False)
$oJson.UpdateBool("properties[7].isRetrievable",True)
$oJson.UpdateBool("properties[7].isQueryable",False)
$oJson.UpdateString("properties[7].labels[0]","url")
$oJson.UpdateNewArray("properties[7].aliases")
$oJson.UpdateString("properties[8].name","description")
$oJson.UpdateString("properties[8].type","string")
$oJson.UpdateBool("properties[8].isSearchable",False)
$oJson.UpdateBool("properties[8].isRetrievable",True)
$oJson.UpdateBool("properties[8].isQueryable",False)
$oJson.UpdateNewArray("properties[8].labels")
$oJson.UpdateNewArray("properties[8].aliases")
$oJson.UpdateString("properties[9].name","authors")
$oJson.UpdateString("properties[9].type","stringCollection")
$oJson.UpdateBool("properties[9].isSearchable",False)
$oJson.UpdateBool("properties[9].isRetrievable",True)
$oJson.UpdateBool("properties[9].isQueryable",False)
$oJson.UpdateString("properties[9].labels[0]","authors")
$oJson.UpdateNewArray("properties[9].aliases")

$oHttp.SetRequestHeader "Content-Type","application/json"
; Adds the "Authorization: Bearer <access_token>" header.
$oHttp.AuthToken = "<access_token>"
$oHttp.SetRequestHeader "prefer","respond-async"

Local $oResp = $oHttp.PostJson3("https://graph.microsoft.com/v1.0/external/connections/sampleConnectionId/schema","application/json",$oJson)
If ($oHttp.LastMethodSuccess = False) Then
    ConsoleWrite($oHttp.LastErrorText & @CRLF)
    Exit
EndIf

ConsoleWrite($oResp.StatusCode & @CRLF)
ConsoleWrite($oResp.BodyStr & @CRLF)

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