Back to Collection Items
#import <CkoHttp.h>
#import <CkoJsonObject.h>
#import <CkoStringBuilder.h>
#import <CkoHttpResponse.h>
// This example assumes the Chilkat API to have been previously unlocked.
// See Global Unlock Sample for sample code.
CkoHttp *http = [[CkoHttp alloc] init];
BOOL success;
// 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"
// }
CkoJsonObject *json = [[CkoJsonObject alloc] init];
[json UpdateString: @"name" value: @"Carson Wentz"];
[json UpdateString: @"address" value: @"100 S. Broad Street"];
[json UpdateString: @"city" value: @"Philadelphia"];
[json UpdateString: @"region" value: @"PA"];
[json UpdateString: @"country" value: @"US"];
[json UpdateString: @"postal" value: @"19103"];
[json UpdateString: @"merchid" value: @"{{merchid}}"];
[json UpdateString: @"account" value: @"{{account}}"];
[json UpdateString: @"expiry" value: @"{{expiry}}"];
[json UpdateString: @"currency" value: @"{{currency}}"];
[json UpdateString: @"profile" value: @"{{profileid}}"];
[json UpdateString: @"profileupdate" value: @"Y"];
[json UpdateString: @"defaultacct" value: @"N"];
[http SetRequestHeader: @"Authorization" value: @"{{Authorization}}"];
[http SetRequestHeader: @"Content-Type" value: @"application/json"];
CkoStringBuilder *sbRequestBody = [[CkoStringBuilder alloc] init];
[json EmitSb: sbRequestBody];
CkoHttpResponse *resp = [http PTextSb: @"PUT" url: @"https://domain.com/profile" textData: sbRequestBody charset: @"utf-8" contentType: @"application/json" md5: NO gzip: NO];
if (http.LastMethodSuccess == NO) {
NSLog(@"%@",http.LastErrorText);
return;
}
NSLog(@"%d",[resp.StatusCode intValue]);
NSLog(@"%@",resp.BodyStr);
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": [
]
}