Back to Collection Items
#import <CkoHttp.h>
#import <CkoJsonObject.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.
// {
// "transactionJournals": [
// {
// "CurrencyIsoCode": "EUR",
// "ActivityDate": "2022-01-04T12:45:19Z",
// "JournalDate": "2022-01-04T00:45:19Z",
// "Brand": "",
// "Establishment": "Apple",
// "ExternalTransactionNumber": "P1-981950",
// "JournalTypeId": "0lET10000004CQp",
// "LoyaltyProgramId": "0lpT10000004CdN",
// "MemberId": "0lMT10000004CfA",
// "TransactionAmount": "117",
// "TransactionLocation": "HitechCity",
// "VoucherCode": "",
// "Origin": "asdf",
// "Distance": "5",
// "Destination": "Hyderabad",
// "FlightNumber": "SF-Ran-001",
// "Status": "Pending"
// }
// ],
// "runSetting": {
// "isSimulation": true
// }
// }
CkoJsonObject *json = [[CkoJsonObject alloc] init];
[json UpdateString: @"transactionJournals[0].CurrencyIsoCode" value: @"EUR"];
[json UpdateString: @"transactionJournals[0].ActivityDate" value: @"2022-01-04T12:45:19Z"];
[json UpdateString: @"transactionJournals[0].JournalDate" value: @"2022-01-04T00:45:19Z"];
[json UpdateString: @"transactionJournals[0].Brand" value: @""];
[json UpdateString: @"transactionJournals[0].Establishment" value: @"Apple"];
[json UpdateString: @"transactionJournals[0].ExternalTransactionNumber" value: @"P1-981950"];
[json UpdateString: @"transactionJournals[0].JournalTypeId" value: @"0lET10000004CQp"];
[json UpdateString: @"transactionJournals[0].LoyaltyProgramId" value: @"0lpT10000004CdN"];
[json UpdateString: @"transactionJournals[0].MemberId" value: @"0lMT10000004CfA"];
[json UpdateString: @"transactionJournals[0].TransactionAmount" value: @"117"];
[json UpdateString: @"transactionJournals[0].TransactionLocation" value: @"HitechCity"];
[json UpdateString: @"transactionJournals[0].VoucherCode" value: @""];
[json UpdateString: @"transactionJournals[0].Origin" value: @"asdf"];
[json UpdateString: @"transactionJournals[0].Distance" value: @"5"];
[json UpdateString: @"transactionJournals[0].Destination" value: @"Hyderabad"];
[json UpdateString: @"transactionJournals[0].FlightNumber" value: @"SF-Ran-001"];
[json UpdateString: @"transactionJournals[0].Status" value: @"Pending"];
[json UpdateBool: @"runSetting.isSimulation" value: YES];
// Adds the "Authorization: Bearer <access_token>" header.
http.AuthToken = @"<access_token>";
CkoHttpResponse *resp = [http PostJson3: @"https://domain.com/services/data/v{{version}}/connect/realtime/loyalty/programs/:loyaltyProgramName" contentType: @"application/json" json: json];
if (http.LastMethodSuccess == NO) {
NSLog(@"%@",http.LastErrorText);
return;
}
NSLog(@"%d",[resp.StatusCode intValue]);
NSLog(@"%@",resp.BodyStr);
Curl Command
curl -X POST
-H "Authorization: Bearer <access_token>"
-d '{
"transactionJournals": [
{
"CurrencyIsoCode": "EUR",
"ActivityDate": "2022-01-04T12:45:19Z",
"JournalDate": "2022-01-04T00:45:19Z",
"Brand": "",
"Establishment": "Apple",
"ExternalTransactionNumber": "P1-981950",
"JournalTypeId": "0lET10000004CQp",
"LoyaltyProgramId": "0lpT10000004CdN",
"MemberId": "0lMT10000004CfA",
"TransactionAmount": "117",
"TransactionLocation": "HitechCity",
"VoucherCode": "",
"Origin": "asdf",
"Distance": "5",
"Destination": "Hyderabad",
"FlightNumber": "SF-Ran-001",
"Status": "Pending"
}
],
"runSetting": {
"isSimulation": true
}
}'
https://domain.com/services/data/v{{version}}/connect/realtime/loyalty/programs/:loyaltyProgramName
Postman Collection Item JSON
{
"name": "Transaction Journals Simulation",
"event": [
{
"listen": "prerequest",
"script": {
"exec": [
"var moment = require('moment');",
"pm.globals.set('currentDatetime', moment().format((\"YYYY-MM-DDTHH:MM:SS\")));"
],
"type": "text/javascript",
"packages": {}
}
}
],
"request": {
"method": "POST",
"header": [
],
"body": {
"mode": "raw",
"raw": "{\n \"transactionJournals\": [\n {\n \"CurrencyIsoCode\": \"EUR\",\n \"ActivityDate\": \"2022-01-04T12:45:19Z\",\n \"JournalDate\": \"2022-01-04T00:45:19Z\",\n \"Brand\": \"\",\n \"Establishment\": \"Apple\",\n \"ExternalTransactionNumber\": \"P1-981950\",\n \"JournalTypeId\": \"0lET10000004CQp\",\n \"LoyaltyProgramId\": \"0lpT10000004CdN\",\n \"MemberId\": \"0lMT10000004CfA\",\n \"TransactionAmount\": \"117\",\n \"TransactionLocation\": \"HitechCity\",\n \"VoucherCode\": \"\",\n \"Origin\": \"asdf\",\n \"Distance\": \"5\",\n \"Destination\": \"Hyderabad\",\n \"FlightNumber\": \"SF-Ran-001\",\n \"Status\": \"Pending\"\n }\n ],\n \"runSetting\": {\n \"isSimulation\": true\n }\n}",
"options": {
"raw": {
"language": "json"
}
}
},
"url": {
"raw": "{{_endpoint}}/services/data/v{{version}}/connect/realtime/loyalty/programs/:loyaltyProgramName",
"host": [
"{{_endpoint}}"
],
"path": [
"services",
"data",
"v{{version}}",
"connect",
"realtime",
"loyalty",
"programs",
":loyaltyProgramName"
],
"variable": [
{
"key": "loyaltyProgramName",
"value": ""
}
]
},
"description": "Standard Documentation:\n\n[https://developer.salesforce.com/docs/atlas.en-us.loyalty.meta/loyalty/connect_resources_loyalty_program_process_simulation.htm](https://developer.salesforce.com/docs/atlas.en-us.loyalty.meta/loyalty/connect_resources_loyalty_program_process_simulation.htm)"
},
"response": [
]
}