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.
// {
// "variables": [
// {
// "name": "Variable100",
// "description": "This denotes variable 100 description",
// "id": "{{variable_id}}"
// }
// ]
// }
var json = new chilkat.JsonObject();
json.UpdateString("variables[0].name","Variable100");
json.UpdateString("variables[0].description","This denotes variable 100 description");
json.UpdateString("variables[0].id","{{variable_id}}");
http.SetRequestHeader("Authorization","{{authorization-token}}");
var sbRequestBody = new chilkat.StringBuilder();
json.EmitSb(sbRequestBody);
// resp: HttpResponse
var resp = http.PTextSb("PUT","https://domain.com/crm/v2.1/settings/variables",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)
// {
// "variables": [
// {
// "code": "SUCCESS",
// "details": {
// "id": "738964000002130241"
// },
// "message": "variable updated",
// "status": "success"
// }
// ]
// }
// Sample code for parsing the JSON response...
// Use this online tool to generate parsing code from sample JSON: Generate JSON Parsing Code
var code;
var Id;
var message;
var status;
var i = 0;
var count_i = jResp.SizeOfArray("variables");
while (i < count_i) {
jResp.I = i;
code = jResp.StringOf("variables[i].code");
Id = jResp.StringOf("variables[i].details.id");
message = jResp.StringOf("variables[i].message");
status = jResp.StringOf("variables[i].status");
i = i+1;
}
}
chilkatExample();
Curl Command
curl -X PUT
-H "Authorization: Bearer <access_token>"
-H "Authorization: {{authorization-token}}"
-d '{
"variables": [
{
"name": "Variable100",
"description": "This denotes variable 100 description",
"id":"{{variable_id}}"
}
]
}'
https://domain.com/crm/v2.1/settings/variables
Postman Collection Item JSON
{
"name": "Update Variables",
"request": {
"auth": {
"type": "bearer",
"bearer": [
{
"key": "token",
"value": "{{access-token}}",
"type": "string"
}
]
},
"method": "PUT",
"header": [
{
"key": "Authorization",
"value": "{{authorization-token}}"
}
],
"body": {
"mode": "raw",
"raw": "{\n \"variables\": [\n {\n \"name\": \"Variable100\",\n \"description\": \"This denotes variable 100 description\",\n \"id\":\"{{variable_id}}\"\n }\n ]\n}",
"options": {
"raw": {
"language": "json"
}
}
},
"url": {
"raw": "{{api-domain}}/crm/v2.1/settings/variables",
"host": [
"{{api-domain}}"
],
"path": [
"crm",
"v2.1",
"settings",
"variables"
]
},
"description": "To update details of variables in CRM."
},
"response": [
{
"name": "SUCCESS RESPONSE",
"originalRequest": {
"method": "PUT",
"header": [
{
"key": "Authorization",
"value": "{{authorization-token}}"
}
],
"body": {
"mode": "raw",
"raw": "{\n \"variables\": [\n {\n \"name\": \"Variable100\",\n \"description\": \"This denotes variable 100 description\",\n \"id\":\"738964000002130241\"\n }\n ]\n}",
"options": {
"raw": {
"language": "json"
}
}
},
"url": {
"raw": "{{api-domain}}/crm/v2.1/settings/variables",
"host": [
"{{api-domain}}"
],
"path": [
"crm",
"v2.1",
"settings",
"variables"
]
}
},
"status": "OK",
"code": 200,
"_postman_previewlanguage": "json",
"header": [
{
"key": "Server",
"value": "ZGS"
},
{
"key": "Date",
"value": "Fri, 07 May 2021 11:32:59 GMT"
},
{
"key": "Content-Type",
"value": "application/json;charset=utf-8"
},
{
"key": "Content-Length",
"value": "120"
},
{
"key": "Connection",
"value": "keep-alive"
},
{
"key": "Referrer-Policy",
"value": "strict-origin"
},
{
"key": "X-Content-Type-Options",
"value": "nosniff"
},
{
"key": "X-XSS-Protection",
"value": "1; mode=block"
},
{
"key": "Pragma",
"value": "no-cache"
},
{
"key": "Cache-Control",
"value": "no-cache"
},
{
"key": "Expires",
"value": "Thu, 01 Jan 1970 00:00:00 GMT"
},
{
"key": "X-Frame-Options",
"value": "SAMEORIGIN"
},
{
"key": "X-ACCESSTOKEN-RESET",
"value": "2021-05-07T12:00:40+00:00"
},
{
"key": "clientVersion",
"value": "4016256"
},
{
"key": "clientsubVersion",
"value": "8ef7aa3133ce0e105307c407d89b23d9"
},
{
"key": "Content-Disposition",
"value": "attachment; filename=response.json"
},
{
"key": "Content-Language",
"value": "en-US"
},
{
"key": "Strict-Transport-Security",
"value": "max-age=15768000"
}
],
"cookie": [
],
"body": "{\n \"variables\": [\n {\n \"code\": \"SUCCESS\",\n \"details\": {\n \"id\": \"738964000002130241\"\n },\n \"message\": \"variable updated\",\n \"status\": \"success\"\n }\n ]\n}"
},
{
"name": "INVALID_URL_PATTERN",
"originalRequest": {
"method": "PUT",
"header": [
{
"key": "Authorization",
"value": "{{authorization-token}}"
}
],
"body": {
"mode": "raw",
"raw": "{\n \"variables\": [\n {\n \"name\": \"Variable100\",\n \"description\": \"This denotes variable 100 description\",\n \"id\":\"{{variable_id}}\"\n }\n ]\n}",
"options": {
"raw": {
"language": "json"
}
}
},
"url": {
"raw": "{{api-domain}}/crm/v2.1/settings/variable",
"host": [
"{{api-domain}}"
],
"path": [
"crm",
"v2.1",
"settings",
"variable"
]
}
},
"status": "Not Found",
"code": 404,
"_postman_previewlanguage": "json",
"header": [
{
"key": "Server",
"value": "ZGS"
},
{
"key": "Date",
"value": "Fri, 07 May 2021 11:36:03 GMT"
},
{
"key": "Content-Type",
"value": "application/json;charset=utf-8"
},
{
"key": "Content-Length",
"value": "131"
},
{
"key": "Connection",
"value": "keep-alive"
},
{
"key": "Referrer-Policy",
"value": "strict-origin"
},
{
"key": "X-Content-Type-Options",
"value": "nosniff"
},
{
"key": "X-XSS-Protection",
"value": "1; mode=block"
},
{
"key": "Pragma",
"value": "no-cache"
},
{
"key": "Cache-Control",
"value": "no-cache"
},
{
"key": "Expires",
"value": "Thu, 01 Jan 1970 00:00:00 GMT"
},
{
"key": "X-Frame-Options",
"value": "SAMEORIGIN"
},
{
"key": "X-ACCESSTOKEN-RESET",
"value": "2021-05-07T12:00:40+00:00"
},
{
"key": "Content-Disposition",
"value": "attachment; filename=response.json"
},
{
"key": "X-Download-Options",
"value": "noopen"
},
{
"key": "Content-Language",
"value": "en-US"
}
],
"cookie": [
],
"body": "{\n \"code\": \"INVALID_URL_PATTERN\",\n \"details\": {},\n \"message\": \"Please check if the URL trying to access is a correct one\",\n \"status\": \"error\"\n}"
},
{
"name": "INVALID_REQUEST_METHOD",
"originalRequest": {
"method": "COPY",
"header": [
{
"key": "Authorization",
"value": "{{authorization-token}}"
}
],
"body": {
"mode": "raw",
"raw": "{\n \"variables\": [\n {\n \"name\": \"Variable100\",\n \"description\": \"This denotes variable 100 description\",\n \"id\":\"{{variable_id}}\"\n }\n ]\n}",
"options": {
"raw": {
"language": "json"
}
}
},
"url": {
"raw": "{{api-domain}}/crm/v2.1/settings/variables",
"host": [
"{{api-domain}}"
],
"path": [
"crm",
"v2.1",
"settings",
"variables"
]
}
},
"status": "Bad Request",
"code": 400,
"_postman_previewlanguage": "json",
"header": [
{
"key": "Server",
"value": "ZGS"
},
{
"key": "Date",
"value": "Fri, 07 May 2021 11:36:22 GMT"
},
{
"key": "Content-Type",
"value": "application/json;charset=utf-8"
},
{
"key": "Content-Length",
"value": "124"
},
{
"key": "Connection",
"value": "keep-alive"
},
{
"key": "X-Frame-Options",
"value": "deny"
},
{
"key": "X-Download-Options",
"value": "noopen"
},
{
"key": "X-Content-Type-Options",
"value": "nosniff"
}
],
"cookie": [
],
"body": "{\n \"code\": \"INVALID_REQUEST_METHOD\",\n \"details\": {},\n \"message\": \"The http request method type is not a valid one\",\n \"status\": \"error\"\n}"
},
{
"name": "PATTERN_NOT_MATCHED",
"originalRequest": {
"method": "PUT",
"header": [
{
"key": "Authorization",
"value": "{{authorization-token}}"
}
],
"body": {
"mode": "raw",
"raw": "{\n \"variables\": [\n {\n \"name\": \"Variable100\",\n \"description\": \"This denotes variable 100 description\",\n \"id\":\"{{variable_id}}\"\n }\n ]\n}",
"options": {
"raw": {
"language": "json"
}
}
},
"url": {
"raw": "{{api-domain}}/crm/v2.1/settings/variables",
"host": [
"{{api-domain}}"
],
"path": [
"crm",
"v2.1",
"settings",
"variables"
]
}
},
"status": "Bad Request",
"code": 400,
"_postman_previewlanguage": "json",
"header": [
{
"key": "Server",
"value": "ZGS"
},
{
"key": "Date",
"value": "Fri, 07 May 2021 11:36:57 GMT"
},
{
"key": "Content-Type",
"value": "application/json;charset=utf-8"
},
{
"key": "Content-Length",
"value": "138"
},
{
"key": "Connection",
"value": "keep-alive"
},
{
"key": "Referrer-Policy",
"value": "strict-origin"
},
{
"key": "X-Content-Type-Options",
"value": "nosniff"
},
{
"key": "X-XSS-Protection",
"value": "1; mode=block"
},
{
"key": "X-Frame-Options",
"value": "SAMEORIGIN"
},
{
"key": "X-Download-Options",
"value": "noopen"
}
],
"cookie": [
],
"body": "{\n \"code\": \"PATTERN_NOT_MATCHED\",\n \"details\": {\n \"api_name\": \"id\"\n },\n \"message\": \"Please check whether the input values are correct\",\n \"status\": \"error\"\n}"
},
{
"name": "DUPLICATE_DATA",
"originalRequest": {
"method": "PUT",
"header": [
{
"key": "Authorization",
"value": "{{authorization-token}}"
}
],
"body": {
"mode": "raw",
"raw": "{\n \"variables\": [\n {\n \"name\": \"Variable100\",\n \"description\": \"This denotes variable 100 description\",\n \"id\":\"738964000002058080\"\n }\n ]\n}",
"options": {
"raw": {
"language": "json"
}
}
},
"url": {
"raw": "{{api-domain}}/crm/v2.1/settings/variables",
"host": [
"{{api-domain}}"
],
"path": [
"crm",
"v2.1",
"settings",
"variables"
]
}
},
"status": "OK",
"code": 200,
"_postman_previewlanguage": "json",
"header": [
{
"key": "Server",
"value": "ZGS"
},
{
"key": "Date",
"value": "Fri, 07 May 2021 11:38:14 GMT"
},
{
"key": "Content-Type",
"value": "application/json;charset=utf-8"
},
{
"key": "Content-Length",
"value": "149"
},
{
"key": "Connection",
"value": "keep-alive"
},
{
"key": "Referrer-Policy",
"value": "strict-origin"
},
{
"key": "X-Content-Type-Options",
"value": "nosniff"
},
{
"key": "X-XSS-Protection",
"value": "1; mode=block"
},
{
"key": "Pragma",
"value": "no-cache"
},
{
"key": "Cache-Control",
"value": "no-cache"
},
{
"key": "Expires",
"value": "Thu, 01 Jan 1970 00:00:00 GMT"
},
{
"key": "X-Frame-Options",
"value": "SAMEORIGIN"
},
{
"key": "X-ACCESSTOKEN-RESET",
"value": "2021-05-07T12:00:40+00:00"
},
{
"key": "clientVersion",
"value": "4016256"
},
{
"key": "clientsubVersion",
"value": "8ef7aa3133ce0e105307c407d89b23d9"
},
{
"key": "Content-Disposition",
"value": "attachment; filename=response.json"
},
{
"key": "Content-Language",
"value": "en-US"
},
{
"key": "Strict-Transport-Security",
"value": "max-age=15768000"
}
],
"cookie": [
],
"body": "{\n \"variables\": [\n {\n \"code\": \"DUPLICATE_DATA\",\n \"details\": {\n \"api_name\": \"name\",\n \"json_path\": \"$.variables[0].name\"\n },\n \"message\": \"duplicate data\",\n \"status\": \"error\"\n }\n ]\n}"
},
{
"name": "MANDATORY_NOT_FOUND",
"originalRequest": {
"method": "PUT",
"header": [
{
"key": "Authorization",
"value": "{{authorization-token}}"
}
],
"body": {
"mode": "raw",
"raw": "{\n \"variables\": [\n {\n \"name\": \"Variable1\",\n \"description\": \"This denotes variable 100 description\",\n }\n ]\n}",
"options": {
"raw": {
"language": "json"
}
}
},
"url": {
"raw": "{{api-domain}}/crm/v2.1/settings/variables",
"host": [
"{{api-domain}}"
],
"path": [
"crm",
"v2.1",
"settings",
"variables"
]
}
},
"status": "OK",
"code": 200,
"_postman_previewlanguage": "json",
"header": [
{
"key": "Server",
"value": "ZGS"
},
{
"key": "Date",
"value": "Fri, 07 May 2021 11:39:04 GMT"
},
{
"key": "Content-Type",
"value": "application/json;charset=utf-8"
},
{
"key": "Content-Length",
"value": "160"
},
{
"key": "Connection",
"value": "keep-alive"
},
{
"key": "Referrer-Policy",
"value": "strict-origin"
},
{
"key": "X-Content-Type-Options",
"value": "nosniff"
},
{
"key": "X-XSS-Protection",
"value": "1; mode=block"
},
{
"key": "Pragma",
"value": "no-cache"
},
{
"key": "Cache-Control",
"value": "no-cache"
},
{
"key": "Expires",
"value": "Thu, 01 Jan 1970 00:00:00 GMT"
},
{
"key": "X-Frame-Options",
"value": "SAMEORIGIN"
},
{
"key": "X-ACCESSTOKEN-RESET",
"value": "2021-05-07T12:00:40+00:00"
},
{
"key": "clientVersion",
"value": "4016256"
},
{
"key": "clientsubVersion",
"value": "8ef7aa3133ce0e105307c407d89b23d9"
},
{
"key": "Content-Disposition",
"value": "attachment; filename=response.json"
},
{
"key": "Content-Language",
"value": "en-US"
},
{
"key": "Strict-Transport-Security",
"value": "max-age=15768000"
}
],
"cookie": [
],
"body": "{\n \"variables\": [\n {\n \"code\": \"MANDATORY_NOT_FOUND\",\n \"details\": {\n \"api_name\": \"id\",\n \"json_path\": \"$.variables[0].id\"\n },\n \"message\": \"required field not found\",\n \"status\": \"error\"\n }\n ]\n}"
},
{
"name": "OAUTH_SCOPE_MISMATCH",
"originalRequest": {
"method": "PUT",
"header": [
{
"key": "Authorization",
"value": "{{authorization-token}}"
}
],
"body": {
"mode": "raw",
"raw": "{\n \"variables\": [\n {\n \"name\": \"Variable100\",\n \"description\": \"This denotes variable 100 description\",\n \"id\":\"{{variable_id}}\"\n }\n ]\n}",
"options": {
"raw": {
"language": "json"
}
}
},
"url": {
"raw": "{{api-domain}}/crm/v2.1/settings/variables",
"host": [
"{{api-domain}}"
],
"path": [
"crm",
"v2.1",
"settings",
"variables"
]
}
},
"status": "Unauthorized",
"code": 401,
"_postman_previewlanguage": "json",
"header": [
{
"key": "Server",
"value": "ZGS"
},
{
"key": "Date",
"value": "Thu, 13 May 2021 08:37:24 GMT"
},
{
"key": "Content-Type",
"value": "application/json;charset=utf-8"
},
{
"key": "Content-Length",
"value": "113"
},
{
"key": "Connection",
"value": "keep-alive"
},
{
"key": "Referrer-Policy",
"value": "strict-origin"
},
{
"key": "X-Content-Type-Options",
"value": "nosniff"
},
{
"key": "X-XSS-Protection",
"value": "1; mode=block"
},
{
"key": "Pragma",
"value": "no-cache"
},
{
"key": "Cache-Control",
"value": "no-cache"
},
{
"key": "Expires",
"value": "Thu, 01 Jan 1970 00:00:00 GMT"
},
{
"key": "X-Frame-Options",
"value": "SAMEORIGIN"
},
{
"key": "X-Download-Options",
"value": "noopen"
}
],
"cookie": [
],
"body": "{\n \"code\": \"OAUTH_SCOPE_MISMATCH\",\n \"details\": {},\n \"message\": \"invalid oauth scope to access this URL\",\n \"status\": \"error\"\n}"
}
]
}