Chilkat Online Tools

Android / Squadcast API V3 / Delete On-call Event

Back to Collection Items

// Important: Don't forget to include the call to System.loadLibrary
// as shown at the bottom of this code sample.
package com.test;

import android.app.Activity;
import com.chilkatsoft.*;

import android.widget.TextView;
import android.os.Bundle;

public class SimpleActivity extends Activity {

  private static final String TAG = "Chilkat";

  // Called when the activity is first created.
  @Override
  public void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);

    // 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.

    // {
    //   "delete_type": 1
    // }

    CkJsonObject json = new CkJsonObject();
    json.UpdateInt("delete_type",1);

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

    CkStringBuilder sbRequestBody = new CkStringBuilder();
    json.EmitSb(sbRequestBody);

    CkHttpResponse resp = http.PTextSb("DELETE","https://api.squadcast.com/v3/schedules/:schedulesID/events/:eventID",sbRequestBody,"utf-8","application/json",false,false);
    if (http.get_LastMethodSuccess() == false) {
        Log.i(TAG, http.lastErrorText());
        return;
        }

    CkStringBuilder sbResponseBody = new CkStringBuilder();
    resp.GetBodySb(sbResponseBody);

    CkJsonObject jResp = new CkJsonObject();
    jResp.LoadSb(sbResponseBody);
    jResp.put_EmitCompact(false);

    Log.i(TAG, "Response Body:");
    Log.i(TAG, jResp.emit());

    int respStatusCode = resp.get_StatusCode();
    Log.i(TAG, "Response Status Code = " + String.valueOf(respStatusCode));
    if (respStatusCode >= 400) {
        Log.i(TAG, "Response Header:");
        Log.i(TAG, resp.header());
        Log.i(TAG, "Failed.");

        return;
        }


  }

  static {
      System.loadLibrary("chilkat");

      // Note: If the incorrect library name is passed to System.loadLibrary,
      // then you will see the following error message at application startup:
      //"The application <your-application-name> has stopped unexpectedly. Please try again."
  }
}

Curl Command

curl -X DELETE
	-H "Authorization: Bearer <access_token>"
	-d '{
	"delete_type":1
}'
https://api.squadcast.com/v3/schedules/:schedulesID/events/:eventID

Postman Collection Item JSON

{
  "name": "Delete On-call Event",
  "request": {
    "method": "DELETE",
    "header": [
    ],
    "body": {
      "mode": "raw",
      "raw": "{\n\t\"delete_type\":1\n}",
      "options": {
        "raw": {
          "language": "json"
        }
      }
    },
    "url": {
      "raw": "{{baseUrl}}/schedules/:schedulesID/events/:eventID",
      "host": [
        "{{baseUrl}}"
      ],
      "path": [
        "schedules",
        ":schedulesID",
        "events",
        ":eventID"
      ],
      "variable": [
        {
          "key": "schedulesID",
          "value": "5ecf7176f92f2e731262b852",
          "type": "string"
        },
        {
          "key": "eventID",
          "value": "5ecf89b4ebddeae2907cd424",
          "type": "string"
        }
      ]
    },
    "description": "This endpoint is used to delete the on-call rotation(event) for the schedule.\nRequires `access_token` as a `Bearer {{token}}` in the `Authorization` header with `schedule-write` scope.\n\nDelete Type value representations:\n```\ndelete_type(*Required)\n\n1 - Delete the current single event\n2 - Delete the current event and all the following events\n```"
  },
  "response": [
    {
      "name": "204 No Content",
      "originalRequest": {
        "method": "DELETE",
        "header": [
        ],
        "body": {
          "mode": "raw",
          "raw": "{\n\t\"delete_type\":1\n}",
          "options": {
            "raw": {
              "language": "json"
            }
          }
        },
        "url": {
          "raw": "{{baseUrl}}/schedules/:schedulesID/events/:eventID",
          "host": [
            "{{baseUrl}}"
          ],
          "path": [
            "schedules",
            ":schedulesID",
            "events",
            ":eventID"
          ],
          "variable": [
            {
              "key": "schedulesID",
              "value": "5ecf7176f92f2e731262b852"
            },
            {
              "key": "eventID",
              "value": "5ecf89b4ebddeae2907cd424"
            }
          ]
        }
      },
      "status": "No Content",
      "code": 204,
      "_postman_previewlanguage": "json",
      "header": [
        {
          "key": "Content-Type",
          "value": "application/json"
        },
        {
          "key": "Vary",
          "value": "Origin"
        },
        {
          "key": "Date",
          "value": "Thu, 28 May 2020 10:28:07 GMT"
        }
      ],
      "cookie": [
      ],
      "body": null
    }
  ]
}