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
-- 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
EXEC sp_OAMethod @http, 'SetRequestHeader', NULL, 'Content-Type', 'application/json'
DECLARE @sbResponseBody int
-- Use "Chilkat_9_5_0.StringBuilder" for versions of Chilkat < 10.0.0
EXEC @hr = sp_OACreate 'Chilkat.StringBuilder', @sbResponseBody OUT
EXEC sp_OAMethod @http, 'QuickGetSb', @success OUT, 'https://domain.com/id/{{_orgId}}/{{_userId}}', @sbResponseBody
IF @success = 0
BEGIN
EXEC sp_OAGetProperty @http, 'LastErrorText', @sTmp0 OUT
PRINT @sTmp0
EXEC @hr = sp_OADestroy @http
EXEC @hr = sp_OADestroy @sbResponseBody
RETURN
END
DECLARE @jResp int
-- Use "Chilkat_9_5_0.JsonObject" for versions of Chilkat < 10.0.0
EXEC @hr = sp_OACreate 'Chilkat.JsonObject', @jResp OUT
EXEC sp_OAMethod @jResp, 'LoadSb', @success OUT, @sbResponseBody
EXEC sp_OASetProperty @jResp, 'EmitCompact', 0
PRINT 'Response Body:'
EXEC sp_OAMethod @jResp, 'Emit', @sTmp0 OUT
PRINT @sTmp0
DECLARE @respStatusCode int
EXEC sp_OAGetProperty @http, 'LastStatus', @respStatusCode OUT
PRINT 'Response Status Code = ' + @respStatusCode
IF @respStatusCode >= 400
BEGIN
PRINT 'Response Header:'
EXEC sp_OAGetProperty @http, 'LastHeader', @sTmp0 OUT
PRINT @sTmp0
PRINT 'Failed.'
EXEC @hr = sp_OADestroy @http
EXEC @hr = sp_OADestroy @sbResponseBody
EXEC @hr = sp_OADestroy @jResp
RETURN
END
-- Sample JSON response:
-- (Sample code for parsing the JSON response is shown below)
-- {
-- "id": "https://login.salesforce.com/id/00D.../005...",
-- "asserted_user": true,
-- "user_id": "005...",
-- "organization_id": "00D...",
-- "username": "<username>",
-- "nick_name": "<nickname>",
-- "display_name": "<display_name>",
-- "email": "<email>",
-- "email_verified": true,
-- "first_name": "<firstname>",
-- "last_name": "<lastname>",
-- "timezone": "Europe/Paris",
-- "photos": {
-- "picture": "https://<my_domain>/profilephoto/005/F",
-- "thumbnail": "https://<my_domain>/profilephoto/005/T"
-- },
-- "addr_street": null,
-- "addr_city": null,
-- "addr_state": null,
-- "addr_country": "FR",
-- "addr_zip": null,
-- "mobile_phone": null,
-- "mobile_phone_verified": false,
-- "is_lightning_login_user": false,
-- "status": {
-- "created_date": null,
-- "body": null
-- },
-- "urls": {
-- "enterprise": "https://<my_domain>/services/Soap/c/{version}/00D...",
-- "metadata": "https://<my_domain>/services/Soap/m/{version}/00D...",
-- "partner": "https://<my_domain>/services/Soap/u/{version}/00D...",
-- "rest": "https://<my_domain>/services/data/v{version}/",
-- "sobjects": "https://<my_domain>/services/data/v{version}/sobjects/",
-- "search": "https://<my_domain>/services/data/v{version}/search/",
-- "query": "https://<my_domain>/services/data/v{version}/query/",
-- "recent": "https://<my_domain>/services/data/v{version}/recent/",
-- "tooling_soap": "https://<my_domain>/services/Soap/T/{version}/00D...",
-- "tooling_rest": "https://<my_domain>/services/data/v{version}/tooling/",
-- "profile": "https://<my_domain>/0052o00000DOJ1PAAX",
-- "feeds": "https://<my_domain>/services/data/v{version}/chatter/feeds",
-- "groups": "https://<my_domain>/services/data/v{version}/chatter/groups",
-- "users": "https://<my_domain>/services/data/v{version}/chatter/users",
-- "feed_items": "https://<my_domain>/services/data/v{version}/chatter/feed-items",
-- "feed_elements": "https://<my_domain>/services/data/v{version}/chatter/feed-elements",
-- "custom_domain": "https://<my_domain>"
-- },
-- "active": true,
-- "user_type": "STANDARD",
-- "language": "en_US",
-- "locale": "fr_FR_EURO",
-- "utcOffset": 3600000,
-- "last_modified_date": "<date_time>",
-- "is_app_installed": true
-- }
-- Sample code for parsing the JSON response...
-- Use this online tool to generate parsing code from sample JSON: Generate JSON Parsing Code
DECLARE @id nvarchar(4000)
EXEC sp_OAMethod @jResp, 'StringOf', @id OUT, 'id'
DECLARE @asserted_user int
EXEC sp_OAMethod @jResp, 'BoolOf', @asserted_user OUT, 'asserted_user'
DECLARE @user_id nvarchar(4000)
EXEC sp_OAMethod @jResp, 'StringOf', @user_id OUT, 'user_id'
DECLARE @organization_id nvarchar(4000)
EXEC sp_OAMethod @jResp, 'StringOf', @organization_id OUT, 'organization_id'
DECLARE @username nvarchar(4000)
EXEC sp_OAMethod @jResp, 'StringOf', @username OUT, 'username'
DECLARE @nick_name nvarchar(4000)
EXEC sp_OAMethod @jResp, 'StringOf', @nick_name OUT, 'nick_name'
DECLARE @display_name nvarchar(4000)
EXEC sp_OAMethod @jResp, 'StringOf', @display_name OUT, 'display_name'
DECLARE @email nvarchar(4000)
EXEC sp_OAMethod @jResp, 'StringOf', @email OUT, 'email'
DECLARE @email_verified int
EXEC sp_OAMethod @jResp, 'BoolOf', @email_verified OUT, 'email_verified'
DECLARE @first_name nvarchar(4000)
EXEC sp_OAMethod @jResp, 'StringOf', @first_name OUT, 'first_name'
DECLARE @last_name nvarchar(4000)
EXEC sp_OAMethod @jResp, 'StringOf', @last_name OUT, 'last_name'
DECLARE @timezone nvarchar(4000)
EXEC sp_OAMethod @jResp, 'StringOf', @timezone OUT, 'timezone'
DECLARE @Picture nvarchar(4000)
EXEC sp_OAMethod @jResp, 'StringOf', @Picture OUT, 'photos.picture'
DECLARE @Thumbnail nvarchar(4000)
EXEC sp_OAMethod @jResp, 'StringOf', @Thumbnail OUT, 'photos.thumbnail'
DECLARE @addr_street nvarchar(4000)
EXEC sp_OAMethod @jResp, 'StringOf', @addr_street OUT, 'addr_street'
DECLARE @addr_city nvarchar(4000)
EXEC sp_OAMethod @jResp, 'StringOf', @addr_city OUT, 'addr_city'
DECLARE @addr_state nvarchar(4000)
EXEC sp_OAMethod @jResp, 'StringOf', @addr_state OUT, 'addr_state'
DECLARE @addr_country nvarchar(4000)
EXEC sp_OAMethod @jResp, 'StringOf', @addr_country OUT, 'addr_country'
DECLARE @addr_zip nvarchar(4000)
EXEC sp_OAMethod @jResp, 'StringOf', @addr_zip OUT, 'addr_zip'
DECLARE @mobile_phone nvarchar(4000)
EXEC sp_OAMethod @jResp, 'StringOf', @mobile_phone OUT, 'mobile_phone'
DECLARE @mobile_phone_verified int
EXEC sp_OAMethod @jResp, 'BoolOf', @mobile_phone_verified OUT, 'mobile_phone_verified'
DECLARE @is_lightning_login_user int
EXEC sp_OAMethod @jResp, 'BoolOf', @is_lightning_login_user OUT, 'is_lightning_login_user'
DECLARE @Created_date nvarchar(4000)
EXEC sp_OAMethod @jResp, 'StringOf', @Created_date OUT, 'status.created_date'
DECLARE @Body nvarchar(4000)
EXEC sp_OAMethod @jResp, 'StringOf', @Body OUT, 'status.body'
DECLARE @Enterprise nvarchar(4000)
EXEC sp_OAMethod @jResp, 'StringOf', @Enterprise OUT, 'urls.enterprise'
DECLARE @Metadata nvarchar(4000)
EXEC sp_OAMethod @jResp, 'StringOf', @Metadata OUT, 'urls.metadata'
DECLARE @Partner nvarchar(4000)
EXEC sp_OAMethod @jResp, 'StringOf', @Partner OUT, 'urls.partner'
DECLARE @v_Rest nvarchar(4000)
EXEC sp_OAMethod @jResp, 'StringOf', @v_Rest OUT, 'urls.rest'
DECLARE @Sobjects nvarchar(4000)
EXEC sp_OAMethod @jResp, 'StringOf', @Sobjects OUT, 'urls.sobjects'
DECLARE @Search nvarchar(4000)
EXEC sp_OAMethod @jResp, 'StringOf', @Search OUT, 'urls.search'
DECLARE @Query nvarchar(4000)
EXEC sp_OAMethod @jResp, 'StringOf', @Query OUT, 'urls.query'
DECLARE @Recent nvarchar(4000)
EXEC sp_OAMethod @jResp, 'StringOf', @Recent OUT, 'urls.recent'
DECLARE @Tooling_soap nvarchar(4000)
EXEC sp_OAMethod @jResp, 'StringOf', @Tooling_soap OUT, 'urls.tooling_soap'
DECLARE @Tooling_rest nvarchar(4000)
EXEC sp_OAMethod @jResp, 'StringOf', @Tooling_rest OUT, 'urls.tooling_rest'
DECLARE @Profile nvarchar(4000)
EXEC sp_OAMethod @jResp, 'StringOf', @Profile OUT, 'urls.profile'
DECLARE @Feeds nvarchar(4000)
EXEC sp_OAMethod @jResp, 'StringOf', @Feeds OUT, 'urls.feeds'
DECLARE @Groups nvarchar(4000)
EXEC sp_OAMethod @jResp, 'StringOf', @Groups OUT, 'urls.groups'
DECLARE @Users nvarchar(4000)
EXEC sp_OAMethod @jResp, 'StringOf', @Users OUT, 'urls.users'
DECLARE @Feed_items nvarchar(4000)
EXEC sp_OAMethod @jResp, 'StringOf', @Feed_items OUT, 'urls.feed_items'
DECLARE @Feed_elements nvarchar(4000)
EXEC sp_OAMethod @jResp, 'StringOf', @Feed_elements OUT, 'urls.feed_elements'
DECLARE @Custom_domain nvarchar(4000)
EXEC sp_OAMethod @jResp, 'StringOf', @Custom_domain OUT, 'urls.custom_domain'
DECLARE @active int
EXEC sp_OAMethod @jResp, 'BoolOf', @active OUT, 'active'
DECLARE @user_type nvarchar(4000)
EXEC sp_OAMethod @jResp, 'StringOf', @user_type OUT, 'user_type'
DECLARE @language nvarchar(4000)
EXEC sp_OAMethod @jResp, 'StringOf', @language OUT, 'language'
DECLARE @locale nvarchar(4000)
EXEC sp_OAMethod @jResp, 'StringOf', @locale OUT, 'locale'
DECLARE @utcOffset int
EXEC sp_OAMethod @jResp, 'IntOf', @utcOffset OUT, 'utcOffset'
DECLARE @last_modified_date nvarchar(4000)
EXEC sp_OAMethod @jResp, 'StringOf', @last_modified_date OUT, 'last_modified_date'
DECLARE @is_app_installed int
EXEC sp_OAMethod @jResp, 'BoolOf', @is_app_installed OUT, 'is_app_installed'
EXEC @hr = sp_OADestroy @http
EXEC @hr = sp_OADestroy @sbResponseBody
EXEC @hr = sp_OADestroy @jResp
END
GO
Curl Command
curl -X GET
-H "Content-Type: application/json"
https://domain.com/id/{{_orgId}}/{{_userId}}
Postman Collection Item JSON
{
"name": "ID Token",
"request": {
"method": "GET",
"header": [
{
"key": "Content-Type",
"type": "text",
"value": "application/json"
}
],
"url": {
"raw": "{{_endpoint}}/id/{{_orgId}}/{{_userId}}",
"host": [
"{{_endpoint}}"
],
"path": [
"id",
"{{_orgId}}",
"{{_userId}}"
]
}
},
"response": [
{
"name": "Successful ID Token",
"originalRequest": {
"method": "GET",
"header": [
{
"key": "Content-Type",
"value": "application/json"
}
],
"url": {
"raw": "{{_endpoint}}/id/{{_orgId}}/{{_userId}}",
"host": [
"{{_endpoint}}"
],
"path": [
"id",
"{{_orgId}}",
"{{_userId}}"
]
}
},
"status": "OK",
"code": 200,
"_postman_previewlanguage": "json",
"header": [
{
"key": "Date",
"value": "Thu, 16 Nov 2023 15:56:09 GMT"
},
{
"key": "Strict-Transport-Security",
"value": "max-age=63072000; includeSubDomains"
},
{
"key": "X-Content-Type-Options",
"value": "nosniff"
},
{
"key": "X-XSS-Protection",
"value": "1; mode=block"
},
{
"key": "X-Robots-Tag",
"value": "none"
},
{
"key": "Cache-Control",
"value": "no-cache,must-revalidate,max-age=0,no-store,private"
},
{
"key": "Content-Type",
"value": "application/json;charset=UTF-8"
},
{
"key": "Vary",
"value": "Accept-Encoding"
},
{
"key": "Content-Encoding",
"value": "gzip"
},
{
"key": "Transfer-Encoding",
"value": "chunked"
}
],
"cookie": [
],
"body": "{\n \"id\": \"https://login.salesforce.com/id/00D.../005...\",\n \"asserted_user\": true,\n \"user_id\": \"005...\",\n \"organization_id\": \"00D...\",\n \"username\": \"<username>\",\n \"nick_name\": \"<nickname>\",\n \"display_name\": \"<display_name>\",\n \"email\": \"<email>\",\n \"email_verified\": true,\n \"first_name\": \"<firstname>\",\n \"last_name\": \"<lastname>\",\n \"timezone\": \"Europe/Paris\",\n \"photos\": {\n \"picture\": \"https://<my_domain>/profilephoto/005/F\",\n \"thumbnail\": \"https://<my_domain>/profilephoto/005/T\"\n },\n \"addr_street\": null,\n \"addr_city\": null,\n \"addr_state\": null,\n \"addr_country\": \"FR\",\n \"addr_zip\": null,\n \"mobile_phone\": null,\n \"mobile_phone_verified\": false,\n \"is_lightning_login_user\": false,\n \"status\": {\n \"created_date\": null,\n \"body\": null\n },\n \"urls\": {\n \"enterprise\": \"https://<my_domain>/services/Soap/c/{version}/00D...\",\n \"metadata\": \"https://<my_domain>/services/Soap/m/{version}/00D...\",\n \"partner\": \"https://<my_domain>/services/Soap/u/{version}/00D...\",\n \"rest\": \"https://<my_domain>/services/data/v{version}/\",\n \"sobjects\": \"https://<my_domain>/services/data/v{version}/sobjects/\",\n \"search\": \"https://<my_domain>/services/data/v{version}/search/\",\n \"query\": \"https://<my_domain>/services/data/v{version}/query/\",\n \"recent\": \"https://<my_domain>/services/data/v{version}/recent/\",\n \"tooling_soap\": \"https://<my_domain>/services/Soap/T/{version}/00D...\",\n \"tooling_rest\": \"https://<my_domain>/services/data/v{version}/tooling/\",\n \"profile\": \"https://<my_domain>/0052o00000DOJ1PAAX\",\n \"feeds\": \"https://<my_domain>/services/data/v{version}/chatter/feeds\",\n \"groups\": \"https://<my_domain>/services/data/v{version}/chatter/groups\",\n \"users\": \"https://<my_domain>/services/data/v{version}/chatter/users\",\n \"feed_items\": \"https://<my_domain>/services/data/v{version}/chatter/feed-items\",\n \"feed_elements\": \"https://<my_domain>/services/data/v{version}/chatter/feed-elements\",\n \"custom_domain\": \"https://<my_domain>\"\n },\n \"active\": true,\n \"user_type\": \"STANDARD\",\n \"language\": \"en_US\",\n \"locale\": \"fr_FR_EURO\",\n \"utcOffset\": 3600000,\n \"last_modified_date\": \"<date_time>\",\n \"is_app_installed\": true\n}"
}
]
}