Sometimes no matter how long you look at something, the answer just doesn't come, even when trying multiple approaches. This is one of them.
Still using libcurl:
This is a working format in straight c-libcurl:
- Code: Select all Expand view RUN
const char *data = "{\r\n \"transactionData\": {\r\n \"transactionType\": \"CreditSale\",\r\n \"method\": \"hostedFields\",\r\n \"submissionType\": \"automatic\",\r\n \"fields\": [\r\n {\r\n \"id\": \"base_amount\",\r\n \"value\": \"1.00\"\r\n },\r\n {\r\n \"id\": \"external_tran_id\",\r\n \"value\": \"ae898295-c8b8-4799-b2c1-88e5067be721\"\r\n },\r\n {\r\n \"id\": \"device_name\",\r\n \"value\": \"Flex-0554\"\r\n }\r\n ]\r\n }\r\n}";
Here is the same code in PHP-CURL:
- Code: Select all Expand view RUN
CURLOPT_POSTFIELDS =>'{
"transactionData": {
"transactionType": "CreditSale",
"method": "hostedFields",
"submissionType": "automatic",
"fields": [
{
"id": "base_amount",
"value": "1.00"
},
{
"id": "external_tran_id",
"value": ""
},
{
"id": "device_name",
"value": "Flex-0554"
}
]
}
}',
and in straight cURL:
- Code: Select all Expand view RUN
--data-raw '{
"transactionData": {
"transactionType": "CreditSale",
"method": "hostedFields",
"submissionType": "automatic",
"fields": [
{
"id": "base_amount",
"value": "1.00"
},
{
"id": "external_tran_id",
"value": ""
},
{
"id": "device_name",
"value": "Flex-0554"
}
]
}
}'
These are values for cPostFields to pass with curl_easy_setopt(hCurl, HB_CURLOPT_POSTFIELDS, cPostFields).
I've viewed a lot of samples, and tried approaches, but I cannot find a "Harbour friendly" format to write this string. Anyone confident on how to approach this ?
Thanks.