Android / Zoho CRM REST APIs / Transfer Users and Delete Role
Back to Collection Items
// Important: Don't forget to include the call to System.loadLibrary
// as shown at the bottom of this code sample.
package com.test;
import android.app.Activity;
import com.chilkatsoft.*;
import android.widget.TextView;
import android.os.Bundle;
public class SimpleActivity extends Activity {
private static final String TAG = "Chilkat";
// Called when the activity is first created.
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
// This example assumes the Chilkat API to have been previously unlocked.
// See Global Unlock Sample for sample code.
CkHttp http = new CkHttp();
boolean success;
// Adds the "Authorization: Bearer <access_token>" header.
http.put_AuthToken("<access_token>");
CkHttpResponse resp = http.QuickRequest("DELETE","https://domain.com/crm/v2.1/settings/roles/738964000002277002?transfer_to_id=738964000002277202");
if (http.get_LastMethodSuccess() == false) {
Log.i(TAG, http.lastErrorText());
return;
}
CkStringBuilder sbResponseBody = new CkStringBuilder();
resp.GetBodySb(sbResponseBody);
CkJsonObject jResp = new CkJsonObject();
jResp.LoadSb(sbResponseBody);
jResp.put_EmitCompact(false);
Log.i(TAG, "Response Body:");
Log.i(TAG, jResp.emit());
int respStatusCode = resp.get_StatusCode();
Log.i(TAG, "Response Status Code = " + String.valueOf(respStatusCode));
if (respStatusCode >= 400) {
Log.i(TAG, "Response Header:");
Log.i(TAG, resp.header());
Log.i(TAG, "Failed.");
return;
}
// Sample JSON response:
// (Sample code for parsing the JSON response is shown below)
// {
// "roles": [
// {
// "code": "SUCCESS",
// "details": {
// "id": "738964000002277002"
// },
// "message": "Role Deleted",
// "status": "success"
// }
// ]
// }
// Sample code for parsing the JSON response...
// Use this online tool to generate parsing code from sample JSON: Generate JSON Parsing Code
String code;
String Id;
String message;
String status;
int i = 0;
int count_i = jResp.SizeOfArray("roles");
while (i < count_i) {
jResp.put_I(i);
code = jResp.stringOf("roles[i].code");
Id = jResp.stringOf("roles[i].details.id");
message = jResp.stringOf("roles[i].message");
status = jResp.stringOf("roles[i].status");
i = i + 1;
}
}
static {
System.loadLibrary("chilkat");
// Note: If the incorrect library name is passed to System.loadLibrary,
// then you will see the following error message at application startup:
//"The application <your-application-name> has stopped unexpectedly. Please try again."
}
}
Curl Command
curl -X DELETE
-H "Authorization: Bearer <access_token>"
https://domain.com/crm/v2.1/settings/roles/738964000002277002?transfer_to_id=738964000002277202
Postman Collection Item JSON
{
"name": "Transfer Users and Delete Role",
"request": {
"auth": {
"type": "bearer",
"bearer": [
{
"key": "token",
"value": "{{access-token}}",
"type": "string"
}
]
},
"method": "DELETE",
"header": [
],
"url": {
"raw": "{{api-domain}}/crm/v2.1/settings/roles/738964000002277002?transfer_to_id=738964000002277202",
"host": [
"{{api-domain}}"
],
"path": [
"crm",
"v2.1",
"settings",
"roles",
"738964000002277002"
],
"query": [
{
"key": "transfer_to_id",
"value": "738964000002277202"
}
]
},
"description": "To transfer users and delete a role."
},
"response": [
{
"name": "SUCCESS RESPONSE",
"originalRequest": {
"method": "DELETE",
"header": [
],
"url": {
"raw": "{{api-domain}}/crm/v2.1/settings/roles/738964000002277002?transfer_to_id=738964000002277202",
"host": [
"{{api-domain}}"
],
"path": [
"crm",
"v2.1",
"settings",
"roles",
"738964000002277002"
],
"query": [
{
"key": "transfer_to_id",
"value": "738964000002277202"
}
]
}
},
"status": "OK",
"code": 200,
"_postman_previewlanguage": "json",
"header": [
{
"key": "Server",
"value": "ZGS"
},
{
"key": "Date",
"value": "Tue, 15 Jun 2021 10:34:13 GMT"
},
{
"key": "Content-Type",
"value": "application/json;charset=utf-8"
},
{
"key": "Content-Length",
"value": "112"
},
{
"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-06-15T11:15:35+00:00"
},
{
"key": "clientVersion",
"value": "4116249"
},
{
"key": "clientsubVersion",
"value": "0a372498832d823bc03c7945101b2b5e"
},
{
"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 \"roles\": [\n {\n \"code\": \"SUCCESS\",\n \"details\": {\n \"id\": \"738964000002277002\"\n },\n \"message\": \"Role Deleted\",\n \"status\": \"success\"\n }\n ]\n}"
},
{
"name": "INVALID_REQUEST_METHOD",
"originalRequest": {
"method": "PATCH",
"header": [
],
"url": {
"raw": "{{api-domain}}/crm/v2.1/settings/roles/738964000002277002?transfer_to_id=738964000002277202",
"host": [
"{{api-domain}}"
],
"path": [
"crm",
"v2.1",
"settings",
"roles",
"738964000002277002"
],
"query": [
{
"key": "transfer_to_id",
"value": "738964000002277202"
}
]
}
},
"status": "Bad Request",
"code": 400,
"_postman_previewlanguage": "json",
"header": [
{
"key": "Server",
"value": "ZGS"
},
{
"key": "Date",
"value": "Tue, 15 Jun 2021 10:35:11 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": "DELETE",
"header": [
],
"url": {
"raw": "{{api-domain}}/crm/v2.1/settings/roles/738964000002277002?transfer_to_id=738964000002277202",
"host": [
"{{api-domain}}"
],
"path": [
"crm",
"v2.1",
"settings",
"roles",
"738964000002277002"
],
"query": [
{
"key": "transfer_to_id",
"value": "738964000002277202"
}
]
}
},
"status": "Unauthorized",
"code": 401,
"_postman_previewlanguage": "json",
"header": [
{
"key": "Server",
"value": "ZGS"
},
{
"key": "Date",
"value": "Tue, 15 Jun 2021 10:35:31 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_DATA (Role ID)",
"originalRequest": {
"method": "DELETE",
"header": [
],
"url": {
"raw": "{{api-domain}}/crm/v2.1/settings/roles/73896400000227700?transfer_to_id=738964000002277202",
"host": [
"{{api-domain}}"
],
"path": [
"crm",
"v2.1",
"settings",
"roles",
"73896400000227700"
],
"query": [
{
"key": "transfer_to_id",
"value": "738964000002277202"
}
]
}
},
"status": "Bad Request",
"code": 400,
"_postman_previewlanguage": "json",
"header": [
{
"key": "Server",
"value": "ZGS"
},
{
"key": "Date",
"value": "Tue, 15 Jun 2021 10:35:54 GMT"
},
{
"key": "Content-Type",
"value": "application/json;charset=utf-8"
},
{
"key": "Content-Length",
"value": "121"
},
{
"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-06-15T11:15:35+00:00"
},
{
"key": "clientVersion",
"value": "4116249"
},
{
"key": "clientsubVersion",
"value": "0a372498832d823bc03c7945101b2b5e"
},
{
"key": "Content-Disposition",
"value": "attachment; filename=response.json"
},
{
"key": "Content-Language",
"value": "en-US"
}
],
"cookie": [
],
"body": "{\n \"code\": \"INVALID_DATA\",\n \"details\": {\n \"resource_path_index\": 2\n },\n \"message\": \"the id given seems to be invalid\",\n \"status\": \"error\"\n}"
},
{
"name": "REQUIRED_PARAM_MISSING",
"originalRequest": {
"method": "DELETE",
"header": [
],
"url": {
"raw": "{{api-domain}}/crm/v2.1/settings/roles/738964000002277002",
"host": [
"{{api-domain}}"
],
"path": [
"crm",
"v2.1",
"settings",
"roles",
"738964000002277002"
]
}
},
"status": "Bad Request",
"code": 400,
"_postman_previewlanguage": "json",
"header": [
{
"key": "Server",
"value": "ZGS"
},
{
"key": "Date",
"value": "Tue, 15 Jun 2021 10:36:27 GMT"
},
{
"key": "Content-Type",
"value": "application/json;charset=utf-8"
},
{
"key": "Content-Length",
"value": "141"
},
{
"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\": \"transfer_to_id\"\n },\n \"message\": \"One of the expected parameter is missing\",\n \"status\": \"error\"\n}"
},
{
"name": "INVALID_DATA (Role ID and Transfer To ID are same)",
"originalRequest": {
"method": "DELETE",
"header": [
],
"url": {
"raw": "{{api-domain}}/crm/v2.1/settings/roles/738964000002277202?transfer_to_id=738964000002277202",
"host": [
"{{api-domain}}"
],
"path": [
"crm",
"v2.1",
"settings",
"roles",
"738964000002277202"
],
"query": [
{
"key": "transfer_to_id",
"value": "738964000002277202"
}
]
}
},
"status": "Bad Request",
"code": 400,
"_postman_previewlanguage": "json",
"header": [
{
"key": "Server",
"value": "ZGS"
},
{
"key": "Date",
"value": "Tue, 15 Jun 2021 10:38:46 GMT"
},
{
"key": "Content-Type",
"value": "application/json;charset=utf-8"
},
{
"key": "Content-Length",
"value": "155"
},
{
"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-06-15T11:15:35+00:00"
},
{
"key": "clientVersion",
"value": "4116249"
},
{
"key": "clientsubVersion",
"value": "0a372498832d823bc03c7945101b2b5e"
},
{
"key": "Content-Disposition",
"value": "attachment; filename=response.json"
},
{
"key": "Content-Language",
"value": "en-US"
}
],
"cookie": [
],
"body": "{\n \"code\": \"INVALID_DATA\",\n \"details\": {\n \"role_status\": \"subordinate | invalid | same_role\",\n \"param_name\": \"transfer_to_id\"\n },\n \"message\": \"invalid id\",\n \"status\": \"error\"\n}"
},
{
"name": "UNABLE_TO_PARSE_DATA_TYPE",
"originalRequest": {
"method": "DELETE",
"header": [
],
"url": {
"raw": "{{api-domain}}/crm/v2.1/settings/roles/738964000002277202?transfer_to_id=\"ID\"",
"host": [
"{{api-domain}}"
],
"path": [
"crm",
"v2.1",
"settings",
"roles",
"738964000002277202"
],
"query": [
{
"key": "transfer_to_id",
"value": "\"ID\""
}
]
}
},
"status": "Bad Request",
"code": 400,
"_postman_previewlanguage": "json",
"header": [
{
"key": "Server",
"value": "ZGS"
},
{
"key": "Date",
"value": "Tue, 15 Jun 2021 10:40:28 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}"
}
]
}