TCL / Zoho CRM REST APIs / Transfer and Delete Pipeline
Back to Collection Items
load ./chilkat.dll
# This example assumes the Chilkat API to have been previously unlocked.
# See Global Unlock Sample for sample code.
set http [new_CkHttp]
# Use this online tool to generate code from sample JSON: Generate Code to Create JSON
# The following JSON is sent in the request body.
# {
# "transfer_pipeline": [
# {
# "pipeline": {
# "from": "{{from}}",
# "to": "{{to}}"
# },
# "stages": [
# {
# "from": "{{from}}",
# "to": "{{to}}"
# }
# ]
# }
# ]
# }
set json [new_CkJsonObject]
CkJsonObject_UpdateString $json "transfer_pipeline[0].pipeline.from" "{{from}}"
CkJsonObject_UpdateString $json "transfer_pipeline[0].pipeline.to" "{{to}}"
CkJsonObject_UpdateString $json "transfer_pipeline[0].stages[0].from" "{{from}}"
CkJsonObject_UpdateString $json "transfer_pipeline[0].stages[0].to" "{{to}}"
# Adds the "Authorization: Bearer <access_token>" header.
CkHttp_put_AuthToken $http "<access_token>"
# resp is a CkHttpResponse
set resp [CkHttp_PostJson3 $http "https://domain.com/crm/v2.1/settings/pipeline/actions/transfer?layout_id={{layout_id}}" "application/json" $json]
if {[CkHttp_get_LastMethodSuccess $http] == 0} then {
puts [CkHttp_lastErrorText $http]
delete_CkHttp $http
delete_CkJsonObject $json
exit
}
set sbResponseBody [new_CkStringBuilder]
CkHttpResponse_GetBodySb $resp $sbResponseBody
set jResp [new_CkJsonObject]
CkJsonObject_LoadSb $jResp $sbResponseBody
CkJsonObject_put_EmitCompact $jResp 0
puts "Response Body:"
puts [CkJsonObject_emit $jResp]
set respStatusCode [CkHttpResponse_get_StatusCode $resp]
puts "Response Status Code = $respStatusCode"
if {$respStatusCode >= 400} then {
puts "Response Header:"
puts [CkHttpResponse_header $resp]
puts "Failed."
delete_CkHttpResponse $resp
delete_CkHttp $http
delete_CkJsonObject $json
delete_CkStringBuilder $sbResponseBody
delete_CkJsonObject $jResp
exit
}
delete_CkHttpResponse $resp
# Sample JSON response:
# (Sample code for parsing the JSON response is shown below)
# {
# "transfer_pipeline": [
# {
# "code": "SUCCESS",
# "details": {
# "job_id": "4150868000005342033"
# },
# "message": "transfer pipeline scheduled 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
set i 0
set count_i [CkJsonObject_SizeOfArray $jResp "transfer_pipeline"]
while {$i < $count_i} {
CkJsonObject_put_I $jResp $i
set code [CkJsonObject_stringOf $jResp "transfer_pipeline[i].code"]
set Job_id [CkJsonObject_stringOf $jResp "transfer_pipeline[i].details.job_id"]
set message [CkJsonObject_stringOf $jResp "transfer_pipeline[i].message"]
set status [CkJsonObject_stringOf $jResp "transfer_pipeline[i].status"]
set i [expr $i + 1]
}
delete_CkHttp $http
delete_CkJsonObject $json
delete_CkStringBuilder $sbResponseBody
delete_CkJsonObject $jResp
Curl Command
curl -X POST
-H "Authorization: Bearer <access_token>"
-d '{
"transfer_pipeline": [
{
"pipeline": {
"from": {{pipeline_id_to_transfer}},
"to": {{pipeline_id_to_be_transferred_to}}
},
"stages": [
{
"from": {{pipeline_id_to_transfer}},
"to": {{pipeline_id_to_be_transferred_to}}
}
]
}
]
}'
https://domain.com/crm/v2.1/settings/pipeline/actions/transfer?layout_id={{layout_id}}
Postman Collection Item JSON
{
"name": "Transfer and Delete Pipeline",
"request": {
"auth": {
"type": "bearer"
},
"method": "POST",
"header": [
],
"body": {
"mode": "raw",
"raw": "{\n \"transfer_pipeline\": [\n {\n \"pipeline\": {\n \"from\": {{pipeline_id_to_transfer}},\n \"to\": {{pipeline_id_to_be_transferred_to}}\n },\n \"stages\": [\n {\n \"from\": {{pipeline_id_to_transfer}},\n \"to\": {{pipeline_id_to_be_transferred_to}}\n }\n ]\n }\n ]\n}",
"options": {
"raw": {
"language": "json"
}
}
},
"url": {
"raw": "{{api-domain}}/crm/v2.1/settings/pipeline/actions/transfer?layout_id={{layout_id}}",
"host": [
"{{api-domain}}"
],
"path": [
"crm",
"v2.1",
"settings",
"pipeline",
"actions",
"transfer"
],
"query": [
{
"key": "layout_id",
"value": "{{layout_id}}"
}
]
},
"description": "To delete a pipeline and transfer the associated stages to another pipeline."
},
"response": [
{
"name": "SUCCESS RESPONSE",
"originalRequest": {
"method": "POST",
"header": [
],
"body": {
"mode": "raw",
"raw": "{\n \"transfer_pipeline\": [\n {\n \"pipeline\": {\n \"from\": \"4150868000001874009\",\n \"to\": \"4150868000001874016\"\n },\n \"stages\": [\n {\n \"from\": \"4150868000000006801\",\n \"to\": \"4150868000000006803\"\n }\n ]\n }\n ]\n}",
"options": {
"raw": {
"language": "json"
}
}
},
"url": {
"raw": "{{api-domain}}/crm/v2.1/settings/pipeline/actions/transfer?layout_id=4150868000000091023",
"host": [
"{{api-domain}}"
],
"path": [
"crm",
"v2.1",
"settings",
"pipeline",
"actions",
"transfer"
],
"query": [
{
"key": "layout_id",
"value": "4150868000000091023"
}
]
}
},
"status": "OK",
"code": 200,
"_postman_previewlanguage": "json",
"header": [
{
"key": "Server",
"value": "ZGS"
},
{
"key": "Date",
"value": "Mon, 10 May 2021 11:07:25 GMT"
},
{
"key": "Content-Type",
"value": "application/json;charset=utf-8"
},
{
"key": "Content-Length",
"value": "157"
},
{
"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-10T17:05:19+05:30"
},
{
"key": "clientVersion",
"value": "4016246"
},
{
"key": "clientsubVersion",
"value": "59f8474ad0046d6a2f6204e0448818d0"
},
{
"key": "Content-Disposition",
"value": "attachment; filename=response.json"
},
{
"key": "Content-Language",
"value": "en-US"
},
{
"key": "Strict-Transport-Security",
"value": "max-age=63072000"
}
],
"cookie": [
],
"body": "{\n \"transfer_pipeline\": [\n {\n \"code\": \"SUCCESS\",\n \"details\": {\n \"job_id\": \"4150868000005342033\"\n },\n \"message\": \"transfer pipeline scheduled successfully\",\n \"status\": \"success\"\n }\n ]\n}"
},
{
"name": "REQUIRED_PARAM_MISSING",
"originalRequest": {
"method": "POST",
"header": [
],
"body": {
"mode": "raw",
"raw": "{\n \"transfer_pipeline\": [\n {\n \"pipeline\": {\n \"from\": \"4150868000001874009\",\n \"to\": \"4150868000001874016\"\n },\n \"stages\": [\n {\n \"from\": \"4150868000000006801\",\n \"to\": \"4150868000000006803\"\n }\n ]\n }\n ]\n}",
"options": {
"raw": {
"language": "json"
}
}
},
"url": {
"raw": "{{api-domain}}/crm/v2.1/settings/pipeline/actions/transfer",
"host": [
"{{api-domain}}"
],
"path": [
"crm",
"v2.1",
"settings",
"pipeline",
"actions",
"transfer"
]
}
},
"status": "Bad Request",
"code": 400,
"_postman_previewlanguage": "json",
"header": [
{
"key": "Server",
"value": "ZGS"
},
{
"key": "Date",
"value": "Mon, 10 May 2021 11:07:47 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\": \"REQUIRED_PARAM_MISSING\",\n \"details\": {\n \"param\": \"layout_id\"\n },\n \"message\": \"One of the expected parameter is missing\",\n \"status\": \"error\"\n}"
},
{
"name": "MANDATORY_NOT_FOUND",
"originalRequest": {
"method": "POST",
"header": [
],
"body": {
"mode": "raw",
"raw": "{\n \"transfer_pipeline\": [\n {\n \"pipeline\": {\n \"to\": \"4150868000001874016\"\n },\n \"stages\": [\n {\n \"from\": \"4150868000000006801\",\n \"to\": \"4150868000000006803\"\n }\n ]\n }\n ]\n}",
"options": {
"raw": {
"language": "json"
}
}
},
"url": {
"raw": "{{api-domain}}/crm/v2.1/settings/pipeline/actions/transfer?layout_id=4150868000000091023",
"host": [
"{{api-domain}}"
],
"path": [
"crm",
"v2.1",
"settings",
"pipeline",
"actions",
"transfer"
],
"query": [
{
"key": "layout_id",
"value": "4150868000000091023"
}
]
}
},
"status": "Bad Request",
"code": 400,
"_postman_previewlanguage": "json",
"header": [
{
"key": "Server",
"value": "ZGS"
},
{
"key": "Date",
"value": "Mon, 10 May 2021 11:08:07 GMT"
},
{
"key": "Content-Type",
"value": "application/json;charset=utf-8"
},
{
"key": "Content-Length",
"value": "192"
},
{
"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-10T17:05:19+05:30"
},
{
"key": "clientVersion",
"value": "4016246"
},
{
"key": "clientsubVersion",
"value": "59f8474ad0046d6a2f6204e0448818d0"
},
{
"key": "Content-Disposition",
"value": "attachment; filename=response.json"
},
{
"key": "Content-Language",
"value": "en-US"
}
],
"cookie": [
],
"body": "{\n \"transfer_pipeline\": [\n {\n \"code\": \"MANDATORY_NOT_FOUND\",\n \"details\": {\n \"api_name\": \"from\",\n \"json_path\": \"$.transfer_pipeline[0].pipeline[0].from\"\n },\n \"message\": \"Required field not found\",\n \"status\": \"error\"\n }\n ]\n}"
},
{
"name": "INVALID_DATA (layout ID)",
"originalRequest": {
"method": "POST",
"header": [
],
"body": {
"mode": "raw",
"raw": "{\n \"transfer_pipeline\": [\n {\n \"pipeline\": {\n \"from\": \"4150868000001874009\",\n \"to\": \"4150868000001874016\"\n },\n \"stages\": [\n {\n \"from\": \"4150868000000006801\",\n \"to\": \"4150868000000006803\"\n }\n ]\n }\n ]\n}",
"options": {
"raw": {
"language": "json"
}
}
},
"url": {
"raw": "{{api-domain}}/crm/v2.1/settings/pipeline/actions/transfer?layout_id=415086800000009102",
"host": [
"{{api-domain}}"
],
"path": [
"crm",
"v2.1",
"settings",
"pipeline",
"actions",
"transfer"
],
"query": [
{
"key": "layout_id",
"value": "415086800000009102"
}
]
}
},
"status": "Bad Request",
"code": 400,
"_postman_previewlanguage": "json",
"header": [
{
"key": "Server",
"value": "ZGS"
},
{
"key": "Date",
"value": "Mon, 10 May 2021 11:08:27 GMT"
},
{
"key": "Content-Type",
"value": "application/json;charset=utf-8"
},
{
"key": "Content-Length",
"value": "107"
},
{
"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-10T17:05:19+05:30"
},
{
"key": "clientVersion",
"value": "4016246"
},
{
"key": "clientsubVersion",
"value": "59f8474ad0046d6a2f6204e0448818d0"
},
{
"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_DATA\",\n \"details\": {\n \"param_name\": \"layout_id\"\n },\n \"message\": \"Invalid layoutid\",\n \"status\": \"error\"\n}"
},
{
"name": "INVALID_DATA (request input)",
"originalRequest": {
"method": "POST",
"header": [
],
"body": {
"mode": "raw",
"raw": "{\n \"transfer_pipeline\": [\n {\n \"pipeline\": {\n \"from\": \"415086800000187400\",\n \"to\": \"4150868000001874016\"\n },\n \"stages\": [\n {\n \"from\": \"4150868000000006801\",\n \"to\": \"4150868000000006803\"\n }\n ]\n }\n ]\n}",
"options": {
"raw": {
"language": "json"
}
}
},
"url": {
"raw": "{{api-domain}}/crm/v2.1/settings/pipeline/actions/transfer?layout_id=4150868000000091023",
"host": [
"{{api-domain}}"
],
"path": [
"crm",
"v2.1",
"settings",
"pipeline",
"actions",
"transfer"
],
"query": [
{
"key": "layout_id",
"value": "4150868000000091023"
}
]
}
},
"status": "Bad Request",
"code": 400,
"_postman_previewlanguage": "json",
"header": [
{
"key": "Server",
"value": "ZGS"
},
{
"key": "Date",
"value": "Mon, 10 May 2021 11:08:51 GMT"
},
{
"key": "Content-Type",
"value": "application/json;charset=utf-8"
},
{
"key": "Content-Length",
"value": "176"
},
{
"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-10T17:05:19+05:30"
},
{
"key": "clientVersion",
"value": "4016246"
},
{
"key": "clientsubVersion",
"value": "59f8474ad0046d6a2f6204e0448818d0"
},
{
"key": "Content-Disposition",
"value": "attachment; filename=response.json"
},
{
"key": "Content-Language",
"value": "en-US"
}
],
"cookie": [
],
"body": "{\n \"transfer_pipeline\": [\n {\n \"code\": \"INVALID_DATA\",\n \"details\": {\n \"api_name\": \"from\",\n \"json_path\": \"$.transfer_pipeline[0].pipeline[0].from\"\n },\n \"message\": \"Invalid from id\",\n \"status\": \"error\"\n }\n ]\n}"
}
]
}