Back to Collection Items
IncludeFile "CkJsonObject.pb"
IncludeFile "CkHttp.pb"
IncludeFile "CkHttpResponse.pb"
Procedure ChilkatExample()
; This example assumes the Chilkat API to have been previously unlocked.
; See Global Unlock Sample for sample code.
http.i = CkHttp::ckCreate()
If http.i = 0
Debug "Failed to create object."
ProcedureReturn
EndIf
success.i
; 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"
; }
json.i = CkJsonObject::ckCreate()
If json.i = 0
Debug "Failed to create object."
ProcedureReturn
EndIf
CkJsonObject::ckUpdateString(json,"userdata.firstName","userFirstName")
CkJsonObject::ckUpdateString(json,"userdata.lastName","userLastName")
CkJsonObject::ckUpdateString(json,"userdata.email","<email>")
CkJsonObject::ckUpdateString(json,"userdata.username","<username>")
CkJsonObject::ckUpdateString(json,"customdata.mobilePhone","+12035408967")
CkJsonObject::ckUpdateString(json,"customdata.streetAddress","12 N Lands End Rd")
CkJsonObject::ckUpdateString(json,"customdata.city","Lantana")
CkJsonObject::ckUpdateString(json,"customdata.state","Florida")
CkJsonObject::ckUpdateString(json,"customdata.zip","20537")
CkJsonObject::ckUpdateBool(json,"customdata.privacyPolicy",1)
CkJsonObject::ckUpdateString(json,"password","Test123!")
CkJsonObject::ckUpdateString(json,"recaptcha","<recaptcha-token>")
CkJsonObject::ckUpdateString(json,"verificationmethod","email")
resp.i = CkHttp::ckPostJson3(http,"https://login.salesforce.com{{site}}/services/auth/headless/init/registration","application/json",json)
If CkHttp::ckLastMethodSuccess(http) = 0
Debug CkHttp::ckLastErrorText(http)
CkHttp::ckDispose(http)
CkJsonObject::ckDispose(json)
ProcedureReturn
EndIf
Debug Str(CkHttpResponse::ckStatusCode(resp))
Debug CkHttpResponse::ckBodyStr(resp)
CkHttpResponse::ckDispose(resp)
CkHttp::ckDispose(http)
CkJsonObject::ckDispose(json)
ProcedureReturn
EndProcedure
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": [
]
}