Back to Collection Items
func chilkatTest() {
// This example assumes the Chilkat API to have been previously unlocked.
// See Global Unlock Sample for sample code.
let http = CkoHttp()!
var success: Bool
// Adds the "Authorization: Bearer <access_token>" header.
http.authToken = "<access_token>"
var resp: CkoHttpResponse? = http.quickRequest("POST", url: "https://domain.com/crm/v2.1/Leads/actions/remove_tags?ids={{record_id1,record_id2,.&tag_names={{tag_name1}},{{tag_name2}}")
if http.lastMethodSuccess == false {
print("\(http.lastErrorText!)")
return
}
let sbResponseBody = CkoStringBuilder()!
resp!.getBodySb(sbResponseBody)
let jResp = CkoJsonObject()!
jResp.loadSb(sbResponseBody)
jResp.emitCompact = false
print("Response Body:")
print("\(jResp.emit()!)")
var respStatusCode: Int = resp!.statusCode.intValue
print("Response Status Code = \(respStatusCode)")
if respStatusCode >= 400 {
print("Response Header:")
print("\(resp!.header!)")
print("Failed.")
resp = nil
return
}
resp = nil
// Sample JSON response:
// (Sample code for parsing the JSON response is shown below)
// {
// "data": [
// {
// "code": "SUCCESS",
// "details": {
// "id": "738964000002131264",
// "tags": [
// ]
// },
// "message": "tags updated successfully",
// "status": "success"
// }
// ],
// "locked_count": "0"
// }
// Sample code for parsing the JSON response...
// Use this online tool to generate parsing code from sample JSON: Generate JSON Parsing Code
var code: String?
var Id: String?
var message: String?
var status: String?
var j: Int
var count_j: Int
var locked_count: String? = jResp.string(of: "locked_count")
var i: Int = 0
var count_i: Int = jResp.size(ofArray: "data").intValue
while i < count_i {
jResp.i = i
code = jResp.string(of: "data[i].code")
Id = jResp.string(of: "data[i].details.id")
message = jResp.string(of: "data[i].message")
status = jResp.string(of: "data[i].status")
j = 0
count_j = jResp.size(ofArray: "data[i].details.tags").intValue
while j < count_j {
jResp.j = j
j = j + 1
}
i = i + 1
}
}
Curl Command
curl -X POST
-H "Authorization: Bearer <access_token>"
https://domain.com/crm/v2.1/Leads/actions/remove_tags?ids={{record_id1,record_id2,..}}&tag_names={{tag_name1}},{{tag_name2}}
Postman Collection Item JSON
{
"name": "Leads",
"request": {
"auth": {
"type": "bearer",
"bearer": [
{
"key": "token",
"value": "{{access-token}}",
"type": "string"
}
]
},
"method": "POST",
"header": [
],
"url": {
"raw": "{{api-domain}}/crm/v2.1/Leads/actions/remove_tags?ids={{record_id1,record_id2,..}}&tag_names={{tag_name1}},{{tag_name2}}",
"host": [
"{{api-domain}}"
],
"path": [
"crm",
"v2.1",
"Leads",
"actions",
"remove_tags"
],
"query": [
{
"key": "ids",
"value": "{{record_id1,record_id2,..}}"
},
{
"key": "tag_names",
"value": "{{tag_name1}},{{tag_name2}}"
}
]
},
"description": "To add tags to records."
},
"response": [
{
"name": "SUCCESS RESPONSE",
"originalRequest": {
"method": "POST",
"header": [
],
"url": {
"raw": "{{api-domain}}/crm/v2.1/Leads/actions/remove_tags?ids=738964000002131264&tag_names=Tag1",
"host": [
"{{api-domain}}"
],
"path": [
"crm",
"v2.1",
"Leads",
"actions",
"remove_tags"
],
"query": [
{
"key": "ids",
"value": "738964000002131264"
},
{
"key": "tag_names",
"value": "Tag1"
}
]
}
},
"status": "OK",
"code": 200,
"_postman_previewlanguage": "json",
"header": [
{
"key": "Server",
"value": "ZGS"
},
{
"key": "Date",
"value": "Fri, 07 May 2021 12:35:44 GMT"
},
{
"key": "Content-Type",
"value": "application/json;charset=utf-8"
},
{
"key": "Content-Length",
"value": "153"
},
{
"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-07T13:13:19+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 \"data\": [\n {\n \"code\": \"SUCCESS\",\n \"details\": {\n \"id\": \"738964000002131264\",\n \"tags\": []\n },\n \"message\": \"tags updated successfully\",\n \"status\": \"success\"\n }\n ],\n \"locked_count\": \"0\"\n}"
},
{
"name": "INVALID_URL_PATTERN",
"originalRequest": {
"method": "POST",
"header": [
],
"url": {
"raw": "{{api-domain}}/crm/v2.1/Leads/actions/remove_tagsids=738964000002131264&tag_names=Tag1",
"host": [
"{{api-domain}}"
],
"path": [
"crm",
"v2.1",
"Leads",
"actions",
"remove_tagsids=738964000002131264&tag_names=Tag1"
]
}
},
"status": "Not Found",
"code": 404,
"_postman_previewlanguage": "json",
"header": [
{
"key": "Server",
"value": "ZGS"
},
{
"key": "Date",
"value": "Fri, 07 May 2021 12:36:17 GMT"
},
{
"key": "Content-Type",
"value": "application/json;charset=utf-8"
},
{
"key": "Content-Length",
"value": "131"
},
{
"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_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": [
],
"url": {
"raw": "{{api-domain}}/crm/v2.1/Leads/actions/remove_tags?ids=738964000002131264&tag_names=Tag1",
"host": [
"{{api-domain}}"
],
"path": [
"crm",
"v2.1",
"Leads",
"actions",
"remove_tags"
],
"query": [
{
"key": "ids",
"value": "738964000002131264"
},
{
"key": "tag_names",
"value": "Tag1"
}
]
}
},
"status": "Bad Request",
"code": 400,
"_postman_previewlanguage": "json",
"header": [
{
"key": "Server",
"value": "ZGS"
},
{
"key": "Date",
"value": "Fri, 07 May 2021 12:36:42 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": "AUTHENTICATION_FAILURE",
"originalRequest": {
"method": "POST",
"header": [
],
"url": {
"raw": "{{api-domain}}/crm/v2.1/Leads/actions/remove_tags?ids=738964000002131264&tag_names=Tag1",
"host": [
"{{api-domain}}"
],
"path": [
"crm",
"v2.1",
"Leads",
"actions",
"remove_tags"
],
"query": [
{
"key": "ids",
"value": "738964000002131264"
},
{
"key": "tag_names",
"value": "Tag1"
}
]
}
},
"status": "Unauthorized",
"code": 401,
"_postman_previewlanguage": "json",
"header": [
{
"key": "Server",
"value": "ZGS"
},
{
"key": "Date",
"value": "Fri, 07 May 2021 12:37:01 GMT"
},
{
"key": "Content-Type",
"value": "application/json;charset=utf-8"
},
{
"key": "Content-Length",
"value": "98"
},
{
"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\": \"AUTHENTICATION_FAILURE\",\n \"details\": {},\n \"message\": \"Authentication failed\",\n \"status\": \"error\"\n}"
},
{
"name": "INVALID_MODULE",
"originalRequest": {
"method": "POST",
"header": [
],
"url": {
"raw": "{{api-domain}}/crm/v2.1/Lead/actions/remove_tags?ids=738964000002131264&tag_names=Tag1",
"host": [
"{{api-domain}}"
],
"path": [
"crm",
"v2.1",
"Lead",
"actions",
"remove_tags"
],
"query": [
{
"key": "ids",
"value": "738964000002131264"
},
{
"key": "tag_names",
"value": "Tag1"
}
]
}
},
"status": "Bad Request",
"code": 400,
"_postman_previewlanguage": "json",
"header": [
{
"key": "Server",
"value": "ZGS"
},
{
"key": "Date",
"value": "Fri, 07 May 2021 12:37:32 GMT"
},
{
"key": "Content-Type",
"value": "application/json;charset=utf-8"
},
{
"key": "Content-Length",
"value": "133"
},
{
"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-07T13:13:19+00:00"
},
{
"key": "clientVersion",
"value": "4016256"
},
{
"key": "clientsubVersion",
"value": "8ef7aa3133ce0e105307c407d89b23d9"
},
{
"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_MODULE\",\n \"details\": {\n \"resource_path_index\": 0\n },\n \"message\": \"the module name given seems to be invalid\",\n \"status\": \"error\"\n}"
}
]
}