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
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.
-- {
-- "userdata": {
-- "firstName": "userFirstName",
-- "lastName": "userLastName",
-- "email": "<email>",
-- "username": "<username>"
-- },
-- "customdata": {
-- "mobilePhone": "+12035408967",
-- "streetAddress": "12 N Lands End Rd",
-- "city": "Lantana",
-- "state": "Florida",
-- "zip": "20537",
-- "privacyPolicy": true
-- },
-- "password": "Test123!",
-- "recaptcha": "<recaptcha-token>",
-- "verificationmethod": "email"
-- }
DECLARE @json int
EXEC @hr = sp_OACreate 'Chilkat.JsonObject', @json OUT
EXEC sp_OAMethod @json, 'UpdateString', @success OUT, 'userdata.firstName', 'userFirstName'
EXEC sp_OAMethod @json, 'UpdateString', @success OUT, 'userdata.lastName', 'userLastName'
EXEC sp_OAMethod @json, 'UpdateString', @success OUT, 'userdata.email', '<email>'
EXEC sp_OAMethod @json, 'UpdateString', @success OUT, 'userdata.username', '<username>'
EXEC sp_OAMethod @json, 'UpdateString', @success OUT, 'customdata.mobilePhone', '+12035408967'
EXEC sp_OAMethod @json, 'UpdateString', @success OUT, 'customdata.streetAddress', '12 N Lands End Rd'
EXEC sp_OAMethod @json, 'UpdateString', @success OUT, 'customdata.city', 'Lantana'
EXEC sp_OAMethod @json, 'UpdateString', @success OUT, 'customdata.state', 'Florida'
EXEC sp_OAMethod @json, 'UpdateString', @success OUT, 'customdata.zip', '20537'
EXEC sp_OAMethod @json, 'UpdateBool', @success OUT, 'customdata.privacyPolicy', 1
EXEC sp_OAMethod @json, 'UpdateString', @success OUT, 'password', 'Test123!'
EXEC sp_OAMethod @json, 'UpdateString', @success OUT, 'recaptcha', '<recaptcha-token>'
EXEC sp_OAMethod @json, 'UpdateString', @success OUT, 'verificationmethod', 'email'
DECLARE @resp int
EXEC @hr = sp_OACreate 'Chilkat.HttpResponse', @resp OUT
EXEC sp_OAMethod @http, 'HttpJson', @success OUT, 'POST', 'https://login.salesforce.com{{site}}/services/auth/headless/init/registration', @json, 'application/json', @resp
IF @success = 0
BEGIN
EXEC sp_OAGetProperty @http, 'LastErrorText', @sTmp0 OUT
PRINT @sTmp0
EXEC @hr = sp_OADestroy @http
EXEC @hr = sp_OADestroy @json
EXEC @hr = sp_OADestroy @resp
RETURN
END
EXEC sp_OAGetProperty @resp, 'StatusCode', @iTmp0 OUT
PRINT @iTmp0
EXEC sp_OAGetProperty @resp, 'BodyStr', @sTmp0 OUT
PRINT @sTmp0
EXEC @hr = sp_OADestroy @http
EXEC @hr = sp_OADestroy @json
EXEC @hr = sp_OADestroy @resp
END
GO
Curl Command
curl -X POST
-d '{
"userdata": {
"firstName": "userFirstName",
"lastName": "userLastName",
"email": "<email>",
"username": "<username>"
},
"customdata": {
"mobilePhone": "+12035408967",
"streetAddress": "12 N Lands End Rd",
"city": "Lantana",
"state": "Florida",
"zip": "20537",
"privacyPolicy": true
},
"password": "Test123!",
"recaptcha": "<recaptcha-token>",
"verificationmethod": "email"
}'
https://login.salesforce.com{{site}}/services/auth/headless/init/registration
Postman Collection Item JSON
{
"name": "Registration - Initialize",
"protocolProfileBehavior": {
"disabledSystemHeaders": {
"content-type": true
}
},
"request": {
"auth": {
"type": "noauth"
},
"method": "POST",
"header": [
],
"body": {
"mode": "raw",
"raw": "{\n \"userdata\": {\n \"firstName\": \"userFirstName\",\n \"lastName\": \"userLastName\",\n \"email\": \"<email>\",\n \"username\": \"<username>\"\n },\n \"customdata\": {\n \"mobilePhone\": \"+12035408967\",\n \"streetAddress\": \"12 N Lands End Rd\",\n \"city\": \"Lantana\",\n \"state\": \"Florida\",\n \"zip\": \"20537\",\n \"privacyPolicy\": true\n },\n \"password\": \"Test123!\",\n \"recaptcha\": \"<recaptcha-token>\",\n \"verificationmethod\": \"email\"\n}",
"options": {
"raw": {
"language": "json"
}
}
},
"url": {
"raw": "{{url}}{{site}}/services/auth/headless/init/registration",
"host": [
"{{url}}{{site}}"
],
"path": [
"services",
"auth",
"headless",
"init",
"registration"
]
},
"description": "Submits the registration data to the init/registration endpoint and returns a request identifier. At the same time, an OTP is sent out to the end users via email or sms. Registration data is passed in the request body, and is formatted with JSON, with 5 keys: `userdata`, `customdata`, `password`, `recaptcha`, and `verificationmethod`. The first two keys are JSON structures, and the last 3 keys are strings.\n\nThis request returns JSON, and includes an identifier (request identifier)."
},
"response": [
]
}