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;
// Use this online tool to generate code from sample JSON: Generate Code to Create JSON
// The following JSON is sent in the request body.
// {
// "name": "Daily Backend schedule",
// "colour": "#0f61dc",
// "description": "This schedule repeats daily"
// }
var json = new chilkat.JsonObject();
json.UpdateString("name","Daily Backend schedule");
json.UpdateString("colour","#0f61dc");
json.UpdateString("description","This schedule repeats daily");
// Adds the "Authorization: Bearer <access_token>" header.
http.AuthToken = "<access_token>";
var sbRequestBody = new chilkat.StringBuilder();
json.EmitSb(sbRequestBody);
// resp: HttpResponse
var resp = http.PTextSb("PUT","https://api.squadcast.com/v3/schedules/:schedulesID",sbRequestBody,"utf-8","application/json",false,false);
if (http.LastMethodSuccess == false) {
console.log(http.LastErrorText);
return;
}
var sbResponseBody = new chilkat.StringBuilder();
resp.GetBodySb(sbResponseBody);
var jResp = new chilkat.JsonObject();
jResp.LoadSb(sbResponseBody);
jResp.EmitCompact = false;
console.log("Response Body:");
console.log(jResp.Emit());
var respStatusCode = resp.StatusCode;
console.log("Response Status Code = " + respStatusCode);
if (respStatusCode >= 400) {
console.log("Response Header:");
console.log(resp.Header);
console.log("Failed.");
return;
}
// Sample JSON response:
// (Sample code for parsing the JSON response is shown below)
// {
// "data": {
// "id": "5ecf73fbf92f2e731262b853",
// "name": "Daily Backend schedule",
// "slug": "daily-schedule",
// "organization_id": "5d81d9187000fb6b9def7e32",
// "colour": "#0f61dc",
// "description": "This schedule repeats daily",
// "organization": {
// "id": "5d81d9187000fb6b9def7e32",
// "name": "GopherHut",
// "slug": "gopherhut"
// }
// }
// }
// Sample code for parsing the JSON response...
// Use this online tool to generate parsing code from sample JSON: Generate JSON Parsing Code
var Id = jResp.StringOf("data.id");
var Name = jResp.StringOf("data.name");
var Slug = jResp.StringOf("data.slug");
var Organization_id = jResp.StringOf("data.organization_id");
var Colour = jResp.StringOf("data.colour");
var Description = jResp.StringOf("data.description");
var OrganizationId = jResp.StringOf("data.organization.id");
var OrganizationName = jResp.StringOf("data.organization.name");
var OrganizationSlug = jResp.StringOf("data.organization.slug");
}
chilkatExample();
Curl Command
curl -X PUT
-H "Authorization: Bearer <access_token>"
-d '{
"name": "Daily Backend schedule",
"colour": "#0f61dc",
"description": "This schedule repeats daily"
}'
https://api.squadcast.com/v3/schedules/:schedulesID
Postman Collection Item JSON
{
"name": "Update Schedule",
"request": {
"method": "PUT",
"header": [
],
"body": {
"mode": "raw",
"raw": "{\n\t\"name\": \"Daily Backend schedule\",\n\t\"colour\": \"#0f61dc\",\n\t\"description\": \"This schedule repeats daily\"\n}",
"options": {
"raw": {
"language": "json"
}
}
},
"url": {
"raw": "{{baseUrl}}/schedules/:schedulesID",
"host": [
"{{baseUrl}}"
],
"path": [
"schedules",
":schedulesID"
],
"variable": [
{
"key": "schedulesID",
"value": "5ecf73fbf92f2e731262b853",
"type": "string"
}
]
},
"description": "This endpoint is used to update a schedule's configuration.\nRequires `access_token` as a `Bearer {{token}}` in the `Authorization` header with `schedule-write` scope."
},
"response": [
{
"name": "200 OK",
"originalRequest": {
"method": "PUT",
"header": [
],
"body": {
"mode": "raw",
"raw": "{\n\t\"name\": \"Daily Backend schedule\",\n\t\"colour\": \"#0f61dc\",\n\t\"description\": \"This schedule repeats daily\"\n}",
"options": {
"raw": {
"language": "json"
}
}
},
"url": {
"raw": "{{baseUrl}}/schedules/:schedulesID",
"host": [
"{{baseUrl}}"
],
"path": [
"schedules",
":schedulesID"
],
"variable": [
{
"key": "schedulesID",
"value": "5ecf73fbf92f2e731262b853"
}
]
}
},
"status": "OK",
"code": 200,
"_postman_previewlanguage": "json",
"header": [
{
"key": "Content-Type",
"value": "application/json"
},
{
"key": "Vary",
"value": "Origin"
},
{
"key": "Date",
"value": "Thu, 28 May 2020 08:37:30 GMT"
},
{
"key": "Content-Length",
"value": "294"
}
],
"cookie": [
],
"body": "{\n \"data\": {\n \"id\": \"5ecf73fbf92f2e731262b853\",\n \"name\": \"Daily Backend schedule\",\n \"slug\": \"daily-schedule\",\n \"organization_id\": \"5d81d9187000fb6b9def7e32\",\n \"colour\": \"#0f61dc\",\n \"description\": \"This schedule repeats daily\",\n \"organization\": {\n \"id\": \"5d81d9187000fb6b9def7e32\",\n \"name\": \"GopherHut\",\n \"slug\": \"gopherhut\"\n }\n }\n}"
},
{
"name": "409 Conflict",
"originalRequest": {
"method": "PUT",
"header": [
],
"body": {
"mode": "raw",
"raw": "{\n\t\"name\": \"Weekly schedule\",\n\t\"colour\": \"#0f61dc\",\n\t\"description\": \"This schedule repeats daily\"\n}",
"options": {
"raw": {
"language": "json"
}
}
},
"url": {
"raw": "{{baseUrl}}/schedules/:schedulesID",
"host": [
"{{baseUrl}}"
],
"path": [
"schedules",
":schedulesID"
],
"variable": [
{
"key": "schedulesID",
"value": "5ecf73fbf92f2e731262b853"
}
]
}
},
"status": "Conflict",
"code": 409,
"_postman_previewlanguage": "json",
"header": [
{
"key": "Content-Type",
"value": "application/json"
},
{
"key": "Vary",
"value": "Origin"
},
{
"key": "Date",
"value": "Thu, 28 May 2020 09:00:58 GMT"
},
{
"key": "Content-Length",
"value": "85"
}
],
"cookie": [
],
"body": "{\n \"meta\": {\n \"status\": 409,\n \"error_message\": \"schedule with the same name already exists\"\n }\n}"
},
{
"name": "400 Bad Request",
"originalRequest": {
"method": "PUT",
"header": [
],
"body": {
"mode": "raw",
"raw": "{\n\t\"name\": \"Daily Backend schedule\",\n\t\"colour\": \"#0f61dc\",\n\t\"description\": \"This schedule repeats daily\"\n}",
"options": {
"raw": {
"language": "json"
}
}
},
"url": {
"raw": "{{baseUrl}}/schedules/:schedulesID",
"host": [
"{{baseUrl}}"
],
"path": [
"schedules",
":schedulesID"
],
"variable": [
{
"key": "schedulesID",
"value": "5ecf73fbf92f2e731262b853"
}
]
}
},
"status": "Bad Request",
"code": 400,
"_postman_previewlanguage": "json",
"header": [
{
"key": "Content-Type",
"value": "application/json"
},
{
"key": "Vary",
"value": "Origin"
},
{
"key": "Date",
"value": "Thu, 28 May 2020 09:01:26 GMT"
},
{
"key": "Content-Length",
"value": "56"
}
],
"cookie": [
],
"body": "{\n \"meta\": {\n \"status\": 400,\n \"error_message\": \"Name required\"\n }\n}"
},
{
"name": "401 Unauthorized",
"originalRequest": {
"method": "PUT",
"header": [
],
"body": {
"mode": "raw",
"raw": "{\n\t\"name\": \"Daily Backend schedule\",\n\t\"colour\": \"#0f61dc\",\n\t\"description\": \"This schedule repeats daily\"\n}",
"options": {
"raw": {
"language": "json"
}
}
},
"url": {
"raw": "{{baseUrl}}/schedules/:schedulesID",
"host": [
"{{baseUrl}}"
],
"path": [
"schedules",
":schedulesID"
],
"variable": [
{
"key": "schedulesID",
"value": "5ecf73fbf92f2e731262b853"
}
]
}
},
"status": "Bad Request",
"code": 400,
"_postman_previewlanguage": "json",
"header": [
{
"key": "Content-Type",
"value": "application/json"
},
{
"key": "Vary",
"value": "Origin"
},
{
"key": "Date",
"value": "Thu, 28 May 2020 09:01:26 GMT"
},
{
"key": "Content-Length",
"value": "56"
}
],
"cookie": [
],
"body": "{\n \"meta\": {\n \"status\": 401,\n \"error_message\": \"<string>\"\n }\n}"
},
{
"name": "500 Internal Server Error",
"originalRequest": {
"method": "PUT",
"header": [
],
"body": {
"mode": "raw",
"raw": "{\n\t\"name\": \"Daily Backend schedule\",\n\t\"colour\": \"#0f61dc\",\n\t\"description\": \"This schedule repeats daily\"\n}",
"options": {
"raw": {
"language": "json"
}
}
},
"url": {
"raw": "{{baseUrl}}/schedules/:schedulesID",
"host": [
"{{baseUrl}}"
],
"path": [
"schedules",
":schedulesID"
],
"variable": [
{
"key": "schedulesID",
"value": "5ecf73fbf92f2e731262b853"
}
]
}
},
"status": "Bad Request",
"code": 400,
"_postman_previewlanguage": "json",
"header": [
{
"key": "Content-Type",
"value": "application/json"
},
{
"key": "Vary",
"value": "Origin"
},
{
"key": "Date",
"value": "Thu, 28 May 2020 09:01:26 GMT"
},
{
"key": "Content-Length",
"value": "56"
}
],
"cookie": [
],
"body": "{\n \"meta\": {\n \"status\": 500,\n \"error_message\": \"<string>\"\n }\n}"
},
{
"name": "403 - Forbidden",
"originalRequest": {
"method": "PUT",
"header": [
],
"body": {
"mode": "raw",
"raw": "{\n\t\"name\": \"Daily Backend schedule\",\n\t\"colour\": \"#0f61dc\",\n\t\"description\": \"This schedule repeats daily\"\n}",
"options": {
"raw": {
"language": "json"
}
}
},
"url": {
"raw": "{{baseUrl}}/schedules/:schedulesID",
"host": [
"{{baseUrl}}"
],
"path": [
"schedules",
":schedulesID"
],
"variable": [
{
"key": "schedulesID",
"value": "5ecf73fbf92f2e731262b853"
}
]
}
},
"status": "Bad Request",
"code": 400,
"_postman_previewlanguage": "json",
"header": [
{
"key": "Content-Type",
"value": "application/json"
},
{
"key": "Vary",
"value": "Origin"
},
{
"key": "Date",
"value": "Thu, 28 May 2020 09:01:26 GMT"
},
{
"key": "Content-Length",
"value": "56"
}
],
"cookie": [
],
"body": "{\n \"meta\": {\n \"status\": 403,\n \"error_message\": \"<string>\"\n }\n}"
},
{
"name": "404 Not Found",
"originalRequest": {
"method": "PUT",
"header": [
],
"body": {
"mode": "raw",
"raw": "{\n\t\"name\": \"Daily Backend schedule\",\n\t\"colour\": \"#0f61dc\",\n\t\"description\": \"This schedule repeats daily\"\n}",
"options": {
"raw": {
"language": "json"
}
}
},
"url": {
"raw": "{{baseUrl}}/schedules/:schedulesID",
"host": [
"{{baseUrl}}"
],
"path": [
"schedules",
":schedulesID"
],
"variable": [
{
"key": "schedulesID",
"value": "5ecf73fbf92f2e731262b854"
}
]
}
},
"status": "Not Found",
"code": 404,
"_postman_previewlanguage": "json",
"header": [
{
"key": "Content-Type",
"value": "application/json"
},
{
"key": "Vary",
"value": "Origin"
},
{
"key": "Date",
"value": "Thu, 28 May 2020 09:07:39 GMT"
},
{
"key": "Content-Length",
"value": "70"
}
],
"cookie": [
],
"body": "{\n \"meta\": {\n \"status\": 404,\n \"error_message\": \"schedule resource not found\"\n }\n}"
}
]
}