Back to Collection Items
var os = require('os');
if (os.platform() == 'win32') {
if (os.arch() == 'ia32') {
var chilkat = require('@chilkat/ck-node21-win-ia32');
} else {
var chilkat = require('@chilkat/ck-node21-win64');
}
} else if (os.platform() == 'linux') {
if (os.arch() == 'arm') {
var chilkat = require('@chilkat/ck-node21-arm');
} else if (os.arch() == 'x86') {
var chilkat = require('@chilkat/ck-node21-linux32');
} else {
var chilkat = require('@chilkat/ck-node21-linux64');
}
} else if (os.platform() == 'darwin') {
if (os.arch() == 'arm64') {
var chilkat = require('@chilkat/ck-node21-mac-m1');
} else {
var chilkat = require('@chilkat/ck-node21-macosx');
}
}
function chilkatExample() {
// This example assumes the Chilkat API to have been previously unlocked.
// See Global Unlock Sample for sample code.
var http = new chilkat.Http();
var 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.
// {
// "productId": 120,
// "countryCode": "US",
// "quantity": 1,
// "unitPrice": 1,
// "customIdentifier": "obucks10",
// "senderName": "John Doe",
// "recipientEmail": "anyone@email.com",
// "recipientPhoneDetails": {
// "countryCode": "ES",
// "phoneNumber": "657829900"
// }
// }
var json = new chilkat.JsonObject();
json.UpdateInt("productId",120);
json.UpdateString("countryCode","US");
json.UpdateInt("quantity",1);
json.UpdateInt("unitPrice",1);
json.UpdateString("customIdentifier","obucks10");
json.UpdateString("senderName","John Doe");
json.UpdateString("recipientEmail","anyone@email.com");
json.UpdateString("recipientPhoneDetails.countryCode","ES");
json.UpdateString("recipientPhoneDetails.phoneNumber","657829900");
http.SetRequestHeader("Content-Type","application/json");
// Adds the "Authorization: Bearer YOUR_ACCESS_TOKEN_HERE" header.
http.AuthToken = "YOUR_ACCESS_TOKEN_HERE";
http.SetRequestHeader("Accept","application/com.reloadly.giftcards-v1+json");
// resp: HttpResponse
var resp = http.PostJson3("https://giftcards.reloadly.com/orders","application/json",json);
if (http.LastMethodSuccess == false) {
console.log(http.LastErrorText);
return;
}
console.log(resp.StatusCode);
console.log(resp.BodyStr);
}
chilkatExample();
Curl Command
curl -X POST
-H "Authorization: Bearer YOUR_ACCESS_TOKEN_HERE"
-H "Accept: application/com.reloadly.giftcards-v1+json"
-H "Content-Type: application/json"
-d '{
"productId": 120,
"countryCode": "US",
"quantity": 1,
"unitPrice": 1,
"customIdentifier": "obucks10",
"senderName": "John Doe",
"recipientEmail": "anyone@email.com",
"recipientPhoneDetails": {
"countryCode": "ES",
"phoneNumber": "657829900"
}
}'
https://giftcards.reloadly.com/orders
Postman Collection Item JSON
{
"name": "Order",
"request": {
"method": "POST",
"header": [
{
"key": "Authorization",
"value": "Bearer YOUR_ACCESS_TOKEN_HERE",
"type": "text"
},
{
"key": "Accept",
"value": "application/com.reloadly.giftcards-v1+json",
"type": "text"
},
{
"key": "Content-Type",
"value": "application/json",
"type": "text"
}
],
"body": {
"mode": "raw",
"raw": "{\r\n \"productId\": 120,\r\n \"countryCode\": \"US\",\r\n \"quantity\": 1,\r\n \"unitPrice\": 1,\r\n \"customIdentifier\": \"obucks10\",\r\n \"senderName\": \"John Doe\",\r\n \"recipientEmail\": \"anyone@email.com\",\r\n \"recipientPhoneDetails\": {\r\n \"countryCode\": \"ES\",\r\n \"phoneNumber\": \"657829900\"\r\n }\r\n}",
"options": {
"raw": {
"language": "json"
}
}
},
"url": {
"raw": "https://giftcards.reloadly.com/orders",
"protocol": "https",
"host": [
"giftcards",
"reloadly",
"com"
],
"path": [
"orders"
]
}
},
"response": [
]
}