Back to Collection Items
; This example assumes the Chilkat API to have been previously unlocked.
; See Global Unlock Sample for sample code.
$oHttp = ObjCreate("Chilkat.Http")
Local $bSuccess
; 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"
; }
$oJson = ObjCreate("Chilkat.JsonObject")
$oJson.UpdateString("name","Carson Wentz")
$oJson.UpdateString("address","100 S. Broad Street")
$oJson.UpdateString("city","Philadelphia")
$oJson.UpdateString("region","PA")
$oJson.UpdateString("country","US")
$oJson.UpdateString("postal","19103")
$oJson.UpdateString("merchid","{{merchid}}")
$oJson.UpdateString("account","{{account}}")
$oJson.UpdateString("expiry","{{expiry}}")
$oJson.UpdateString("currency","{{currency}}")
$oJson.UpdateString("profile","{{profileid}}")
$oJson.UpdateString("profileupdate","Y")
$oJson.UpdateString("defaultacct","N")
$oHttp.SetRequestHeader "Authorization","{{Authorization}}"
$oHttp.SetRequestHeader "Content-Type","application/json"
$oSbRequestBody = ObjCreate("Chilkat.StringBuilder")
$oJson.EmitSb($oSbRequestBody)
Local $oResp = $oHttp.PTextSb("PUT","https://domain.com/profile",$oSbRequestBody,"utf-8","application/json",False,False)
If ($oHttp.LastMethodSuccess = False) Then
ConsoleWrite($oHttp.LastErrorText & @CRLF)
Exit
EndIf
ConsoleWrite($oResp.StatusCode & @CRLF)
ConsoleWrite($oResp.BodyStr & @CRLF)
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": [
]
}