ERROR!
------------------- GenerateCode ----------------------
ImpliedContentType: application/json
explicitContentType: application/json
---- begin chilkat script ----
// This example assumes the Chilkat API to have been previously unlocked.
// See {{-global_unlock:::Global Unlock Sample-}} for sample code.
new Http http;
ckbool success;
// Use this online tool to generate code from sample JSON: {{.https://tools.chilkat.io/jsonCreate|||Generate Code to Create JSON.}}
// The following JSON is sent in the request body.
// {
// "requests": [
// {
// "entityTypes": [
// "driveItem"
// ],
// "query": {
// "queryString": "contoso",
// "queryString": "contoso filetype:pdf OR filetype:docx",
// "queryString": "contoso path:\"https://contoso.sharepoint.com/sites/Team Site/Documents/\\"
// }
// }
// ]
// }
new JsonObject json;
ignore = json.UpdateString("requests[0].entityTypes[0]","driveItem");
ignore = json.UpdateString("requests[0].query.queryString","contoso");
ignore = json.UpdateString("requests[0].query.queryString","contoso filetype:pdf OR filetype:docx");
ignore = json.UpdateString("requests[0].query.queryString","contoso path:\"https://contoso.sharepoint.com/sites/Team Site/Documents/\");
// Adds the "Authorization: Bearer <access_token>" header.
http.AuthToken = "<access_token>";
call http.SetRequestHeader("Content-Type","application/json");
HttpResponse resp = http.PostJson3("https://graph.microsoft.com/beta/search/query","application/json",json);
if (http.LastMethodSuccess == ckfalse) {
println http.LastErrorText;
return;
}
println resp.StatusCode;
println resp.BodyStr;
delete resp;
---- end chilkat script ----
SQL Server / Microsoft Graph / Search files and folders
Back to Collection Items
-- Important: See this note about string length limitations for strings returned by sp_OAMethod calls.
--
CREATE PROCEDURE ChilkatSample
AS
BEGIN
DECLARE @hr int
-- This example assumes the Chilkat API to have been previously unlocked.
-- See Global Unlock Sample for sample code.
DECLARE @http int
-- Use "Chilkat_9_5_0.Http" for versions of Chilkat < 10.0.0
EXEC @hr = sp_OACreate 'Chilkat.Http', @http OUT
IF @hr <> 0
BEGIN
PRINT 'Failed to create ActiveX component'
RETURN
END
DECLARE @success int
-- Use this online tool to generate code from sample JSON: Generate Code to Create JSON
-- The following JSON is sent in the request body.
-- {
-- "requests": [
-- {
-- "entityTypes": [
-- "driveItem"
-- ],
-- "query": {
-- "queryString": "contoso",
-- "queryString": "contoso filetype:pdf OR filetype:docx",
-- "queryString": "contoso path:\"https://contoso.sharepoint.com/sites/Team Site/Documents/\\"
-- }
-- }
-- ]
-- }
DECLARE @json int
-- Use "Chilkat_9_5_0.JsonObject" for versions of Chilkat < 10.0.0
EXEC @hr = sp_OACreate 'Chilkat.JsonObject', @json OUT
EXEC sp_OAMethod @json, 'UpdateString', @success OUT, 'requests[0].entityTypes[0]', 'driveItem'
EXEC sp_OAMethod @json, 'UpdateString', @success OUT, 'requests[0].query.queryString', 'contoso'
EXEC sp_OAMethod @json, 'UpdateString', @success OUT, 'requests[0].query.queryString', 'contoso filetype:pdf OR filetype:docx'
ERROR: invalid unaryExpression
ERROR: No et type for expression.
ERROR: No expression type in SQL
ERROR: xExpr =
<unnamed/>
EXEC sp_OAMethod @json, 'UpdateString', @success OUT, 'requests[0].query.queryString',
EXEC @hr = sp_OADestroy @http
EXEC @hr = sp_OADestroy @json
END
GO
Curl Command
curl -X POST
-H "Authorization: Bearer <access_token>"
-H "Content-Type: application/json"
-d '{
"requests": [
{
"entityTypes": [
"driveItem"
],
"query": {
"queryString": "contoso"
//"queryString": "contoso filetype:pdf OR filetype:docx"
//"queryString": "contoso path:\"https://contoso.sharepoint.com/sites/Team Site/Documents/\\""
}
}
]
}'
https://graph.microsoft.com/beta/search/query
Postman Collection Item JSON
{
"name": "Search files and folders",
"request": {
"method": "POST",
"header": [
{
"key": "Content-Type",
"name": "Content-Type",
"value": "application/json",
"type": "text"
}
],
"body": {
"mode": "raw",
"raw": "{\n \"requests\": [\n {\n \"entityTypes\": [\n \"driveItem\"\n ],\n \"query\": {\n \"queryString\": \"contoso\"\n //\"queryString\": \"contoso filetype:pdf OR filetype:docx\"\n //\"queryString\": \"contoso path:\\\"https://contoso.sharepoint.com/sites/Team Site/Documents/\\\\\"\" \n }\n }\n ]\n}"
},
"url": {
"raw": "https://graph.microsoft.com/beta/search/query",
"protocol": "https",
"host": [
"graph",
"microsoft",
"com"
],
"path": [
"beta",
"search",
"query"
]
}
},
"response": [
]
}