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
// Use this online tool to generate code from sample JSON: Generate Code to Create JSON
// The following JSON is sent in the request body.
// {
// "tags": [
// {
// "conflict_id": "{{id of the tag which you want to merge}}"
// }
// ]
// }
let json = CkoJsonObject()
json.UpdateString("tags[0].conflict_id", value: "{{id of the tag which you want to merge}}")
// Adds the "Authorization: Bearer <access_token>" header.
http.AuthToken = "<access_token>"
var resp: CkoHttpResponse? = http.PostJson3("https://domain.com/crm/v2/settings/tags/{{tag_id}}/actions/merge", contentType: "application/json", json: json)
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)
// {
// "tags": [
// {
// "code": "SUCCESS",
// "details": {
// "created_time": "2021-05-07T12:38:01+00:00",
// "modified_time": "2021-05-12T06:47:47+00:00",
// "modified_by": {
// "name": "Patricia Boyle",
// "id": "738964000000291009"
// },
// "id": "738964000002130340",
// "created_by": {
// "name": "Patricia Boyle",
// "id": "738964000000291009"
// }
// },
// "message": "tags merged successfully",
// "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: String?
var Created_time: String?
var Modified_time: String?
var Name: String?
var Id: String?
var detailsId: String?
var Created_byName: String?
var Created_byId: String?
var message: String?
var status: String?
var i: Int = 0
var count_i: Int = jResp.SizeOfArray("tags").intValue
while i < count_i {
jResp.I = i
code = jResp.StringOf("tags[i].code")
Created_time = jResp.StringOf("tags[i].details.created_time")
Modified_time = jResp.StringOf("tags[i].details.modified_time")
Name = jResp.StringOf("tags[i].details.modified_by.name")
Id = jResp.StringOf("tags[i].details.modified_by.id")
detailsId = jResp.StringOf("tags[i].details.id")
Created_byName = jResp.StringOf("tags[i].details.created_by.name")
Created_byId = jResp.StringOf("tags[i].details.created_by.id")
message = jResp.StringOf("tags[i].message")
status = jResp.StringOf("tags[i].status")
i = i + 1
}
}
Curl Command
curl -X POST
-H "Authorization: Bearer <access_token>"
-d '{
"tags": [
{
"conflict_id": "{{id of the tag which you want to merge}}"
}
]
}'
https://domain.com/crm/v2/settings/tags/{{tag_id}}/actions/merge
Postman Collection Item JSON
{
"name": "Merge Tags",
"request": {
"auth": {
"type": "bearer",
"bearer": [
{
"key": "token",
"value": "{{access-token}}",
"type": "string"
}
]
},
"method": "POST",
"header": [
],
"body": {
"mode": "raw",
"raw": "{\n \"tags\": [\n {\n \"conflict_id\": \"{{id of the tag which you want to merge}}\"\n }\n ]\n}",
"options": {
"raw": {
"language": "json"
}
}
},
"url": {
"raw": "{{api-domain}}/crm/v2/settings/tags/{{tag_id}}/actions/merge",
"host": [
"{{api-domain}}"
],
"path": [
"crm",
"v2",
"settings",
"tags",
"{{tag_id}}",
"actions",
"merge"
]
},
"description": "To merge tags and put all the records under the two tags into a single tag."
},
"response": [
{
"name": "SUCCESS RESPONSE",
"originalRequest": {
"method": "POST",
"header": [
],
"body": {
"mode": "raw",
"raw": "{\n \"tags\": [\n {\n \"conflict_id\": \"738964000002130340\"\n }\n ]\n}",
"options": {
"raw": {
"language": "json"
}
}
},
"url": {
"raw": "{{api-domain}}/crm/v2/settings/tags/738964000002130339/actions/merge",
"host": [
"{{api-domain}}"
],
"path": [
"crm",
"v2",
"settings",
"tags",
"738964000002130339",
"actions",
"merge"
]
}
},
"status": "OK",
"code": 200,
"_postman_previewlanguage": "json",
"header": [
{
"key": "Server",
"value": "ZGS"
},
{
"key": "Date",
"value": "Wed, 12 May 2021 06:47:47 GMT"
},
{
"key": "Content-Type",
"value": "application/json;charset=utf-8"
},
{
"key": "Content-Length",
"value": "341"
},
{
"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-store, no-cache, must-revalidate, private"
},
{
"key": "Expires",
"value": "Thu, 01 Jan 1970 00:00:00 GMT"
},
{
"key": "X-Frame-Options",
"value": "SAMEORIGIN"
},
{
"key": "X-ACCESSTOKEN-RESET",
"value": "2021-05-12T07:15:06+00:00"
},
{
"key": "clientVersion",
"value": "4027076"
},
{
"key": "clientsubVersion",
"value": "748ecbe82ec7e144b66ee25f264bbd88"
},
{
"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 \"tags\": [\n {\n \"code\": \"SUCCESS\",\n \"details\": {\n \"created_time\": \"2021-05-07T12:38:01+00:00\",\n \"modified_time\": \"2021-05-12T06:47:47+00:00\",\n \"modified_by\": {\n \"name\": \"Patricia Boyle\",\n \"id\": \"738964000000291009\"\n },\n \"id\": \"738964000002130340\",\n \"created_by\": {\n \"name\": \"Patricia Boyle\",\n \"id\": \"738964000000291009\"\n }\n },\n \"message\": \"tags merged successfully\",\n \"status\": \"success\"\n }\n ]\n}"
},
{
"name": "INVALID_URL_PATTERN",
"originalRequest": {
"method": "POST",
"header": [
],
"body": {
"mode": "raw",
"raw": "{\n \"tags\": [\n {\n \"conflict_id\": \"{{id of the tag which you want to merge}}\"\n }\n ]\n}",
"options": {
"raw": {
"language": "json"
}
}
},
"url": {
"raw": "{{api-domain}}/crm/v2/settings/tags/738964000002130339/actions/merg",
"host": [
"{{api-domain}}"
],
"path": [
"crm",
"v2",
"settings",
"tags",
"738964000002130339",
"actions",
"merg"
]
}
},
"status": "Not Found",
"code": 404,
"_postman_previewlanguage": "json",
"header": [
{
"key": "Server",
"value": "ZGS"
},
{
"key": "Date",
"value": "Wed, 12 May 2021 06:48:26 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": [
],
"body": {
"mode": "raw",
"raw": "{\n \"tags\": [\n {\n \"conflict_id\": \"{{id of the tag which you want to merge}}\"\n }\n ]\n}",
"options": {
"raw": {
"language": "json"
}
}
},
"url": {
"raw": "{{api-domain}}/crm/v2/settings/tags/738964000002130339/actions/merge",
"host": [
"{{api-domain}}"
],
"path": [
"crm",
"v2",
"settings",
"tags",
"738964000002130339",
"actions",
"merge"
]
}
},
"status": "Bad Request",
"code": 400,
"_postman_previewlanguage": "json",
"header": [
{
"key": "Server",
"value": "ZGS"
},
{
"key": "Date",
"value": "Wed, 12 May 2021 06:48:46 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": "UNABLE_TO_PARSE_DATA_TYPE",
"originalRequest": {
"method": "POST",
"header": [
],
"body": {
"mode": "raw",
"raw": "{\n \"tags\": [\n {\n \"conflict_id\": \"{{id of the tag which you want to merge}}\"\n }\n ]\n}",
"options": {
"raw": {
"language": "json"
}
}
},
"url": {
"raw": "{{api-domain}}/crm/v2/settings/tags/738964000002130339/actions/merge",
"host": [
"{{api-domain}}"
],
"path": [
"crm",
"v2",
"settings",
"tags",
"738964000002130339",
"actions",
"merge"
]
}
},
"status": "Bad Request",
"code": 400,
"_postman_previewlanguage": "json",
"header": [
{
"key": "Server",
"value": "ZGS"
},
{
"key": "Date",
"value": "Wed, 12 May 2021 06:49:02 GMT"
},
{
"key": "Content-Type",
"value": "application/json;charset=utf-8"
},
{
"key": "Content-Length",
"value": "136"
},
{
"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\": \"UNABLE_TO_PARSE_DATA_TYPE\",\n \"details\": {},\n \"message\": \"either the request body or parameters is in wrong format\",\n \"status\": \"error\"\n}"
},
{
"name": "AUTHENTICATION_FAILURE",
"originalRequest": {
"method": "POST",
"header": [
],
"body": {
"mode": "raw",
"raw": "{\n \"tags\": [\n {\n \"conflict_id\": \"738964000002130340\"\n }\n ]\n}",
"options": {
"raw": {
"language": "json"
}
}
},
"url": {
"raw": "{{api-domain}}/crm/v2/settings/tags/738964000002130339/actions/merge",
"host": [
"{{api-domain}}"
],
"path": [
"crm",
"v2",
"settings",
"tags",
"738964000002130339",
"actions",
"merge"
]
}
},
"status": "Unauthorized",
"code": 401,
"_postman_previewlanguage": "json",
"header": [
{
"key": "Server",
"value": "ZGS"
},
{
"key": "Date",
"value": "Wed, 12 May 2021 06:50:02 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": "MANDATORY_NOT_FOUND",
"originalRequest": {
"method": "POST",
"header": [
],
"body": {
"mode": "raw",
"raw": "{\n \"tags\": [\n {\n \n }\n ]\n}",
"options": {
"raw": {
"language": "json"
}
}
},
"url": {
"raw": "{{api-domain}}/crm/v2/settings/tags/738964000002130339/actions/merge",
"host": [
"{{api-domain}}"
],
"path": [
"crm",
"v2",
"settings",
"tags",
"738964000002130339",
"actions",
"merge"
]
}
},
"status": "OK",
"code": 200,
"_postman_previewlanguage": "json",
"header": [
{
"key": "Server",
"value": "ZGS"
},
{
"key": "Date",
"value": "Wed, 12 May 2021 06:50:21 GMT"
},
{
"key": "Content-Type",
"value": "application/json;charset=utf-8"
},
{
"key": "Content-Length",
"value": "132"
},
{
"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-store, no-cache, must-revalidate, private"
},
{
"key": "Expires",
"value": "Thu, 01 Jan 1970 00:00:00 GMT"
},
{
"key": "X-Frame-Options",
"value": "SAMEORIGIN"
},
{
"key": "X-ACCESSTOKEN-RESET",
"value": "2021-05-12T07:15:06+00:00"
},
{
"key": "clientVersion",
"value": "4027076"
},
{
"key": "clientsubVersion",
"value": "748ecbe82ec7e144b66ee25f264bbd88"
},
{
"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 \"tags\": [\n {\n \"code\": \"MANDATORY_NOT_FOUND\",\n \"details\": {\n \"api_name\": \"conflict_id\"\n },\n \"message\": \"required field not found\",\n \"status\": \"error\"\n }\n ]\n}"
}
]
}