Chilkat Online Tools

Java / Salesforce Platform APIs / Unenroll a Member

Back to Collection Items

import com.chilkatsoft.*;

public class ChilkatExample {

  static {
    try {
        System.loadLibrary("chilkat");
    } catch (UnsatisfiedLinkError e) {
      System.err.println("Native code library failed to load.\n" + e);
      System.exit(1);
    }
  }

  public static void main(String argv[])
  {
    // This example assumes the Chilkat API to have been previously unlocked.
    // See Global Unlock Sample for sample code.

    CkHttp http = new CkHttp();
    boolean 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.

    // {
    //   "processParameters": [
    //     {
    //       "MemberId": "0lMRM0000004G6f2AE"
    //     }
    //   ]
    // }

    CkJsonObject json = new CkJsonObject();
    json.UpdateString("processParameters[0].MemberId","0lMRM0000004G6f2AE");

    // Adds the "Authorization: Bearer <access_token>" header.
    http.put_AuthToken("<access_token>");

    CkHttpResponse resp = http.PostJson3("https://domain.com/services/data/v{{version}}/connect/loyalty/programs/:loyaltyProgramName/program-processes/:processName","application/json",json);
    if (http.get_LastMethodSuccess() == false) {
        System.out.println(http.lastErrorText());
        return;
        }

    System.out.println(resp.get_StatusCode());
    System.out.println(resp.bodyStr());
  }
}

Curl Command

curl -X POST
	-H "Authorization: Bearer <access_token>"
	-d '{
   "processParameters":[
      {
         "MemberId":"0lMRM0000004G6f2AE"
      }
   ]
}'
https://domain.com/services/data/v{{version}}/connect/loyalty/programs/:loyaltyProgramName/program-processes/:processName

Postman Collection Item JSON

{
  "name": "Unenroll a Member",
  "event": [
    {
      "listen": "prerequest",
      "script": {
        "exec": [
          "//pm.variables.set('loyaltyProgramName','xyz');",
          "pm.variables.set('processName','UnenrollMember');"
        ],
        "type": "text/javascript",
        "packages": {}
      }
    }
  ],
  "request": {
    "method": "POST",
    "header": [
    ],
    "body": {
      "mode": "raw",
      "raw": "\n{\n   \"processParameters\":[\n      {\n         \"MemberId\":\"0lMRM0000004G6f2AE\"\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": "[Unenroll a Member](https://developer.salesforce.com/docs/atlas.en-us.loyalty.meta/loyalty/connect_resources_unenroll_member.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{\n   \"processParameters\":[\n      {\n         \"MemberId\":\"0lMRM0000004G6f2AE\"\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": [
        ],
        "body": {
          "mode": "raw",
          "raw": "\n{\n   \"processParameters\":[\n      {\n         \"MemberId\":\"0lMRM0000004G6f2AE\"\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
    }
  ]
}