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
DECLARE @iTmp0 int
-- Important: Do not use nvarchar(max). See the warning about using nvarchar(max).
DECLARE @sTmp0 nvarchar(4000)
-- 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
DECLARE @queryParams int
-- Use "Chilkat_9_5_0.JsonObject" for versions of Chilkat < 10.0.0
EXEC @hr = sp_OACreate 'Chilkat.JsonObject', @queryParams OUT
EXEC sp_OAMethod @queryParams, 'UpdateString', @success OUT, 'q', ''
EXEC sp_OAMethod @queryParams, 'UpdateString', @success OUT, 'language', ''
-- Adds the "Authorization: Bearer <access_token>" header.
EXEC sp_OASetProperty @http, 'AuthToken', '<access_token>'
EXEC sp_OAMethod @http, 'SetRequestHeader', NULL, 'Content-Type', 'application/json'
DECLARE @resp int
EXEC sp_OAMethod @http, 'QuickRequestParams', @resp OUT, 'GET', 'https://domain.com/services/data/v{{version}}/search/suggestSearchQueries', @queryParams
EXEC sp_OAGetProperty @http, 'LastMethodSuccess', @iTmp0 OUT
IF @iTmp0 = 0
BEGIN
EXEC sp_OAGetProperty @http, 'LastErrorText', @sTmp0 OUT
PRINT @sTmp0
EXEC @hr = sp_OADestroy @http
EXEC @hr = sp_OADestroy @queryParams
RETURN
END
EXEC sp_OAGetProperty @resp, 'StatusCode', @iTmp0 OUT
PRINT @iTmp0
EXEC sp_OAGetProperty @resp, 'BodyStr', @sTmp0 OUT
PRINT @sTmp0
EXEC @hr = sp_OADestroy @resp
EXEC @hr = sp_OADestroy @http
EXEC @hr = sp_OADestroy @queryParams
END
GO
Curl Command
curl -G -d "q="
-d "language="
-H "Authorization: Bearer <access_token>"
-H "Content-Type: application/json"
https://domain.com/services/data/v{{version}}/search/suggestSearchQueries
Postman Collection Item JSON
{
"name": "Search Suggested Queries",
"protocolProfileBehavior": {
"disableBodyPruning": true
},
"request": {
"method": "GET",
"header": [
{
"key": "Content-Type",
"value": "application/json"
}
],
"body": {
"mode": "raw",
"raw": ""
},
"url": {
"raw": "{{_endpoint}}/services/data/v{{version}}/search/suggestSearchQueries?q&language",
"host": [
"{{_endpoint}}"
],
"path": [
"services",
"data",
"v{{version}}",
"search",
"suggestSearchQueries"
],
"query": [
{
"key": "channel",
"value": "",
"description": "Optional. Specifies the Salesforce Knowledge channel where the article can be viewed. Valid values:\nAllChannels–Visible in all channels the user has access to\nApp–Visible in the internal Salesforce Knowledge application\nPkb–Visible in the public knowledge base\nCsp–Visible in the Customer Portal\nPrm–Visible in the Partner Portal\nIf channel isn’t specified, the default value is determined by the type of user.\nPkb for a guest user\nCsp for a Customer Portal user\nPrm for a Partner Portal user\nApp for any other type of user\nIf channel is specified, the specified value may not be the actual value requested, because of certain requirements.\nFor guest, Customer Portal, and Partner Portal users, the specified value must match the default value for each user type. If the values don’t match or AllChannels is specified, then App replaces the specified value.\nFor all users other than guest, Customer Portal, and Partner Portal users:\nIf Pkb, Csp, Prm, or App are specified, then the specified value is used.\nIf AllChannels is specified, then App replaces the specified value.",
"disabled": true
},
{
"key": "limit",
"value": null,
"description": "Optional. Specifies the maximum number of suggested searches to return. If there are more suggested queries than the limit specified, the response body’s hasMoreResults property is true.",
"disabled": true
},
{
"key": "q",
"value": null
},
{
"key": "language",
"value": null
}
]
},
"description": "Returns a list of suggested searches based on the user’s query string text matching searches that other users have performed in Salesforce Knowledge. Provides a way to improve search effectiveness, before the user performs a search.\n\nhttps://developer.salesforce.com/docs/atlas.en-us.api_rest.meta/api_rest/resources_search_suggest_queries.htm"
},
"response": [
]
}