Back to Collection Items
// This example assumes the Chilkat API to have been previously unlocked.
// See Global Unlock Sample for sample code.
loHttp = createobject("CkHttp")
// Use this online tool to generate code from sample JSON: Generate Code to Create JSON
// The following JSON is sent in the request body.
// {
// "name": "Carson Wentz",
// "address": "100 S. Broad Street",
// "city": "Philadelphia",
// "region": "PA",
// "country": "US",
// "postal": "19103",
// "merchid": "{{merchid}}",
// "account": "{{account}}",
// "expiry": "{{expiry}}",
// "currency": "{{currency}}",
// "profile": "{{profileid}}",
// "profileupdate": "Y",
// "defaultacct": "N"
// }
loJson = createobject("CkJsonObject")
loJson.UpdateString("name","Carson Wentz")
loJson.UpdateString("address","100 S. Broad Street")
loJson.UpdateString("city","Philadelphia")
loJson.UpdateString("region","PA")
loJson.UpdateString("country","US")
loJson.UpdateString("postal","19103")
loJson.UpdateString("merchid","{{merchid}}")
loJson.UpdateString("account","{{account}}")
loJson.UpdateString("expiry","{{expiry}}")
loJson.UpdateString("currency","{{currency}}")
loJson.UpdateString("profile","{{profileid}}")
loJson.UpdateString("profileupdate","Y")
loJson.UpdateString("defaultacct","N")
loHttp.SetRequestHeader("Authorization","{{Authorization}}")
loHttp.SetRequestHeader("Content-Type","application/json")
loSbRequestBody = createobject("CkStringBuilder")
loJson.EmitSb(loSbRequestBody)
loResp = loHttp.PTextSb("PUT","https://domain.com/profile",loSbRequestBody,"utf-8","application/json",.F.,.F.)
if (loHttp.LastMethodSuccess = .F.) then
? loHttp.LastErrorText
release loHttp
release loJson
release loSbRequestBody
return
endif
? str(loResp.StatusCode)
? loResp.BodyStr
release loResp
release loHttp
release loJson
release loSbRequestBody
Curl Command
curl -X PUT
-H "Authorization: {{Authorization}}"
-H "Content-Type: application/json"
-d '{
"name": "Carson Wentz",
"address": "100 S. Broad Street",
"city": "Philadelphia",
"region": "PA",
"country": "US",
"postal": "19103",
"merchid": "{{merchid}}",
"account": "{{account}}",
"expiry": "{{expiry}}",
"currency": "{{currency}}",
"profile": "{{profileid}}",
"profileupdate": "Y",
"defaultacct": "N"
}'
https://domain.com/profile
Postman Collection Item JSON
{
"name": "Profile (New account/token/card)",
"event": [
{
"listen": "test",
"script": {
"exec": [
"var jsonData = JSON.parse(responseBody);",
"postman.setEnvironmentVariable(\"profileid\", jsonData.profileid);",
"var jsonData = JSON.parse(responseBody);",
"postman.setEnvironmentVariable(\"acctid\", jsonData.acctid);"
],
"type": "text/javascript"
}
}
],
"request": {
"method": "PUT",
"header": [
{
"key": "Authorization",
"value": "{{Authorization}}"
},
{
"key": "Content-Type",
"value": "application/json"
}
],
"body": {
"mode": "raw",
"raw": "{\n \"name\": \"Carson Wentz\",\n \"address\": \"100 S. Broad Street\",\n \"city\": \"Philadelphia\",\n \"region\": \"PA\",\n \"country\": \"US\",\n \"postal\": \"19103\",\n \"merchid\": \"{{merchid}}\",\n \"account\": \"{{account}}\",\n \"expiry\": \"{{expiry}}\",\n \"currency\": \"{{currency}}\",\n \"profile\": \"{{profileid}}\",\n \"profileupdate\": \"Y\",\n \"defaultacct\": \"N\"\n}"
},
"url": {
"raw": "{{url}}/profile",
"host": [
"{{url}}"
],
"path": [
"profile"
]
},
"description": "[Profile Documentation](https://developer.cardconnect.com/cardconnect-api#profile)\n\n**Notes:** \n* To create subaccounts on an existing profile\n* acctid = n + 1"
},
"response": [
]
}