Back to Collection Items
// This example assumes the Chilkat API to have been previously unlocked.
// See Global_Ref.html">Global Unlock Sample for sample code.
http := chilkat.NewHttp()
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.
// {
// "processParameters": [
// {
// "MemberId": "0lMxx00000000BJEAY",
// "VoucherCode": "15OFF",
// "VoucherFaceValue": 15,
// "VoucherExpirationDate": "2022-07-13"
// }
// ]
// }
json := chilkat.NewJsonObject()
json.UpdateString("processParameters[0].MemberId","0lMxx00000000BJEAY")
json.UpdateString("processParameters[0].VoucherCode","15OFF")
json.UpdateInt("processParameters[0].VoucherFaceValue",15)
json.UpdateString("processParameters[0].VoucherExpirationDate","2022-07-13")
// Adds the "Authorization: Bearer <access_token>" header.
http.SetAuthToken("<access_token>")
resp := http.PostJson3("https://domain.com/services/data/v{{version}}/connect/loyalty/programs/:loyaltyProgramName/program-processes/:processName","application/json",json)
if http.LastMethodSuccess() == false {
fmt.Println(http.LastErrorText())
http.DisposeHttp()
json.DisposeJsonObject()
return
}
fmt.Println(resp.StatusCode())
fmt.Println(resp.BodyStr())
resp.DisposeHttpResponse()
http.DisposeHttp()
json.DisposeJsonObject()
Curl Command
curl -X POST
-H "Authorization: Bearer <access_token>"
-d '{
"processParameters":[
{
"MemberId":"0lMxx00000000BJEAY",
"VoucherCode":"15OFF",
"VoucherFaceValue":15,
"VoucherExpirationDate":"2022-07-13"
}
]
}'
https://domain.com/services/data/v{{version}}/connect/loyalty/programs/:loyaltyProgramName/program-processes/:processName
Postman Collection Item JSON
{
"name": "Issue a Voucher",
"event": [
{
"listen": "prerequest",
"script": {
"exec": [
"//pm.variables.set('loyaltyProgramName','xyz');",
"pm.variables.set('processName','IssueVoucher');"
],
"type": "text/javascript",
"packages": {}
}
}
],
"request": {
"method": "POST",
"header": [
],
"body": {
"mode": "raw",
"raw": "{\n \"processParameters\":[\n {\n \"MemberId\":\"0lMxx00000000BJEAY\",\n \"VoucherCode\":\"15OFF\",\n \"VoucherFaceValue\":15,\n \"VoucherExpirationDate\":\"2022-07-13\"\n }\n ]\n}",
"options": {
"raw": {
"language": "json"
}
}
},
"url": {
"raw": "{{_endpoint}}/services/data/v{{version}}/connect/loyalty/programs/:loyaltyProgramName/program-processes/:processName",
"host": [
"{{_endpoint}}"
],
"path": [
"services",
"data",
"v{{version}}",
"connect",
"loyalty",
"programs",
":loyaltyProgramName",
"program-processes",
":processName"
],
"query": [
{
"key": "journalTypeId",
"value": "",
"disabled": true
}
],
"variable": [
{
"key": "loyaltyProgramName"
},
{
"key": "processName"
}
]
},
"description": "[Issue a Voucher](https://developer.salesforce.com/docs/atlas.en-us.loyalty.meta/loyalty/connect_resources_issue_voucher.htm)\n\nNOTE:\n\nIn the Pre-request. Script Tab, make changes in the variables value accordingly with the real Process Name to invoke."
},
"response": [
{
"name": "example with a member ID",
"originalRequest": {
"method": "POST",
"header": [
],
"body": {
"mode": "raw",
"raw": "{\n \"processParameters\":[\n {\n \"MemberId\":\"0lMxx00000000BJEAY\",\n \"VoucherCode\":\"15OFF\",\n \"VoucherFaceValue\":15,\n \"VoucherExpirationDate\":\"2022-07-13\"\n }\n ]\n}",
"options": {
"raw": {
"language": "json"
}
}
},
"url": {
"raw": "https://itab2c--devloyalty.sandbox.my.salesforce.com/services/data/v60.0/connect/loyalty/programs/Volare/program-processes/processName",
"protocol": "https",
"host": [
"itab2c--devloyalty",
"sandbox",
"my",
"salesforce",
"com"
],
"path": [
"services",
"data",
"v60.0",
"connect",
"loyalty",
"programs",
"Volare",
"program-processes",
"processName"
],
"query": [
{
"key": "journalTypeId",
"value": null,
"disabled": true
}
]
}
},
"_postman_previewlanguage": null,
"header": null,
"cookie": [
],
"body": null
},
{
"name": "example with a membership number",
"originalRequest": {
"method": "POST",
"header": [
{
"key": "Authorization",
"value": "Bearer {{accessToken}}"
}
],
"body": {
"mode": "raw",
"raw": "{\n \"processParameters\":[\n {\n \"MembershipNumber\":\"003\",\n \"VoucherCode\":\"15OFF\",\n \"VoucherDiscountPercentage\":20\n }\n ]\n}",
"options": {
"raw": {
"language": "json"
}
}
},
"url": {
"raw": "{{_endpoint}}/services/data/v{{version}}/connect/loyalty/programs/:loyaltyProgramName/program-processes/:processName",
"host": [
"{{_endpoint}}"
],
"path": [
"services",
"data",
"v{{version}}",
"connect",
"loyalty",
"programs",
":loyaltyProgramName",
"program-processes",
":processName"
],
"query": [
{
"key": "journalTypeId",
"value": null,
"disabled": true
}
],
"variable": [
{
"key": "loyaltyProgramName"
},
{
"key": "processName"
}
]
}
},
"_postman_previewlanguage": null,
"header": null,
"cookie": [
],
"body": null
}
]
}