Back to Collection Items
func chilkatTest() {
// This example assumes the Chilkat API to have been previously unlocked.
// See Global Unlock Sample for sample code.
let http = CkoHttp()!
var success: Bool
// 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"
// }
// }
let json = CkoJsonObject()!
json.updateInt("productId", value: 120)
json.update("countryCode", value: "US")
json.updateInt("quantity", value: 1)
json.updateInt("unitPrice", value: 1)
json.update("customIdentifier", value: "obucks10")
json.update("senderName", value: "John Doe")
json.update("recipientEmail", value: "anyone@email.com")
json.update("recipientPhoneDetails.countryCode", value: "ES")
json.update("recipientPhoneDetails.phoneNumber", value: "657829900")
http.setRequestHeader("Content-Type", value: "application/json")
// Adds the "Authorization: Bearer YOUR_ACCESS_TOKEN_HERE" header.
http.authToken = "YOUR_ACCESS_TOKEN_HERE"
http.setRequestHeader("Accept", value: "application/com.reloadly.giftcards-v1+json")
var resp: CkoHttpResponse? = http.postJson3("https://giftcards.reloadly.com/orders", contentType: "application/json", json: json)
if http.lastMethodSuccess == false {
print("\(http.lastErrorText!)")
return
}
print("\(resp!.statusCode.intValue)")
print("\(resp!.bodyStr!)")
resp = nil
}
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": [
]
}