Chilkat Online Tools

DataFlex / Plivo REST API / Delete an Application

Back to Collection Items

Use ChilkatAx-9.5.0-win32.pkg

Procedure Test
    Handle hoHttp
    Boolean iSuccess
    Handle hoJson
    Variant vSbRequestBody
    Handle hoSbRequestBody
    Variant vResp
    Handle hoResp
    Integer iRespStatusCode
    String sTemp1
    Boolean bTemp1

    // This example assumes the Chilkat API to have been previously unlocked.
    // See Global Unlock Sample for sample code.

    Get Create (RefClass(cComChilkatHttp)) To hoHttp
    If (Not(IsComObjectCreated(hoHttp))) Begin
        Send CreateComObject of hoHttp
    End

    Set ComBasicAuth Of hoHttp To True
    Set ComLogin Of hoHttp To "{{auth_id}}"
    Set ComPassword Of hoHttp To "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"
    // }

    Get Create (RefClass(cComChilkatJsonObject)) To hoJson
    If (Not(IsComObjectCreated(hoJson))) Begin
        Send CreateComObject of hoJson
    End
    Get ComUpdateString Of hoJson "cascade" "true" To iSuccess
    Get ComUpdateString Of hoJson "new_endpoint_application" "77506472664956327" To iSuccess

    Get Create (RefClass(cComChilkatStringBuilder)) To hoSbRequestBody
    If (Not(IsComObjectCreated(hoSbRequestBody))) Begin
        Send CreateComObject of hoSbRequestBody
    End
    Get pvComObject of hoSbRequestBody to vSbRequestBody
    Get ComEmitSb Of hoJson vSbRequestBody To iSuccess

    Get pvComObject of hoSbRequestBody to vSbRequestBody
    Get ComPTextSb Of hoHttp "DELETE" "https://api.plivo.com/v1/Account/{auth_id}/Application/{app_id}/" vSbRequestBody "utf-8" "application/json" False False To vResp
    If (IsComObject(vResp)) Begin
        Get Create (RefClass(cComChilkatHttpResponse)) To hoResp
        Set pvComObject Of hoResp To vResp
    End
    Get ComLastMethodSuccess Of hoHttp To bTemp1
    If (bTemp1 = False) Begin
        Get ComLastErrorText Of hoHttp To sTemp1
        Showln sTemp1
        Procedure_Return
    End

    Get ComStatusCode Of hoResp To iRespStatusCode
    Showln "Response Status Code = " iRespStatusCode
    If (iRespStatusCode <> 204) Begin
        Showln "Response Header:"
        Get ComHeader Of hoResp To sTemp1
        Showln sTemp1
        Showln "Response Body:"
        Get ComBodyStr Of hoResp To sTemp1
        Showln sTemp1
        Showln "Failed."
        Send Destroy of hoResp
        Procedure_Return
    End

    Send Destroy of hoResp
    Showln "Success."


End_Procedure

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": ""
    }
  ]
}