Chilkat Online Tools

Node.js / Plivo REST API / Delete an Application

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;

    http.BasicAuth = true;
    http.Login = "{{auth_id}}";
    http.Password = "password";

    // Use this online tool to generate code from sample JSON: Generate Code to Create JSON

    // The following JSON is sent in the request body.

    // {
    //   "cascade": "true",
    //   "new_endpoint_application": "77506472664956327"
    // }

    var json = new chilkat.JsonObject();
    json.UpdateString("cascade","true");
    json.UpdateString("new_endpoint_application","77506472664956327");

    var sbRequestBody = new chilkat.StringBuilder();
    json.EmitSb(sbRequestBody);

    // resp: HttpResponse
    var resp = http.PTextSb("DELETE","https://api.plivo.com/v1/Account/{auth_id}/Application/{app_id}/",sbRequestBody,"utf-8","application/json",false,false);
    if (http.LastMethodSuccess == false) {
        console.log(http.LastErrorText);
        return;
    }

    var respStatusCode = resp.StatusCode;
    console.log("Response Status Code = " + respStatusCode);
    if (respStatusCode !== 204) {
        console.log("Response Header:");
        console.log(resp.Header);
        console.log("Response Body:");
        console.log(resp.BodyStr);
        console.log("Failed.");

        return;
    }

    console.log("Success.");

}

chilkatExample();

Curl Command

curl -X DELETE
	-u '{{auth_id}}:password'
	-d '{
    "cascade":"true",
    "new_endpoint_application":"77506472664956327"
}'
https://api.plivo.com/v1/Account/{auth_id}/Application/{app_id}/

Postman Collection Item JSON

{
  "name": "Delete an Application",
  "request": {
    "method": "DELETE",
    "header": [
    ],
    "body": {
      "mode": "raw",
      "raw": "{\n    \"cascade\":\"true\",\n    \"new_endpoint_application\":\"77506472664956327\"\n}",
      "options": {
        "raw": {
          "language": "json"
        }
      }
    },
    "url": {
      "raw": "https://api.plivo.com/v1/Account/{auth_id}/Application/{app_id}/",
      "protocol": "https",
      "host": [
        "api",
        "plivo",
        "com"
      ],
      "path": [
        "v1",
        "Account",
        "{auth_id}",
        "Application",
        "{app_id}",
        ""
      ]
    },
    "description": "This API would delete the Application permanently.\n\nBelow is the list of arguments that can be passed in this API request, more information can be found [here](https://www.plivo.com/docs/sms/api/message#send-a-message)\n\n| Arguments   | Description | Required/Conditional/Optional     |\n| :---        |    :----:   |          ---: |\n| cascade      | If cascade is set to true, the Endpoints associated with the Application, if any, are also deleted.When set to false, the Endpoints associated with the Application, if any, are not deleted. <br />If a new_endpoint_application has been specified, then the Endpoints are reassociated with the given Application. If a new_endpoint_application is not specified, then the Endpoints remain orphaned. (i.e. not associated with any Application.)cascade is set to true by default when not specified.| Optional  |\n| new_endpoint_application   | The app_id of the new Application to which the Endpoints should be associated upon deletion of this Application. | Required |"
  },
  "response": [
    {
      "name": "Delete an Application",
      "originalRequest": {
        "method": "DELETE",
        "header": [
        ],
        "body": {
          "mode": "raw",
          "raw": "{\n    \"cascade\":\"true\",\n    \"new_endpoint_application\":\"77506472664956327\"\n}",
          "options": {
            "raw": {
              "language": "json"
            }
          }
        },
        "url": {
          "raw": "https://api.plivo.com/v1/Account/{auth_id}/Application/{app_id}/",
          "protocol": "https",
          "host": [
            "api",
            "plivo",
            "com"
          ],
          "path": [
            "v1",
            "Account",
            "{auth_id}",
            "Application",
            "{app_id}",
            ""
          ]
        }
      },
      "code": 204,
      "_postman_previewlanguage": "Text",
      "header": [
      ],
      "cookie": [
      ],
      "body": ""
    }
  ]
}