Chilkat Online Tools

Android / Zoho CRM REST APIs / Assign Territories

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;

    // Use this online tool to generate code from sample JSON: Generate Code to Create JSON

    // The following JSON is sent in the request body.

    // {
    //   "data": [
    //     {
    //       "id": "{{record_id1}}",
    //       "Territories": [
    //         {
    //           "id": "{{territory_id1}}"
    //         },
    //         {
    //           "id": "{{territory_id2}}"
    //         }
    //       ]
    //     },
    //     {
    //       "id": "{{record_id2}}",
    //       "Territories": [
    //         {
    //           "id": "{{territory_id1}}"
    //         },
    //         {
    //           "id": "{{territory_id2}}"
    //         }
    //       ]
    //     }
    //   ]
    // }

    CkJsonObject json = new CkJsonObject();
    json.UpdateString("data[0].id","{{record_id1}}");
    json.UpdateString("data[0].Territories[0].id","{{territory_id1}}");
    json.UpdateString("data[0].Territories[1].id","{{territory_id2}}");
    json.UpdateString("data[1].id","{{record_id2}}");
    json.UpdateString("data[1].Territories[0].id","{{territory_id1}}");
    json.UpdateString("data[1].Territories[1].id","{{territory_id2}}");

    // Adds the "Authorization: Bearer <access_token>" header.
    http.put_AuthToken("<access_token>");

    CkHttpResponse resp = http.PostJson3("https://domain.com/crm/v2.1/Accounts/actions/assign_territories","application/json",json);
    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)

    // {
    //   "data": [
    //     {
    //       "code": "SUCCESS",
    //       "details": {
    //         "id": "4150868000004818104"
    //       },
    //       "message": "the territories data updated successfully",
    //       "status": "success"
    //     },
    //     {
    //       "code": "SUCCESS",
    //       "details": {
    //         "id": "4150868000004818029"
    //       },
    //       "message": "the territories data updated 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

    String code;
    String Id;
    String message;
    String status;

    int i = 0;
    int count_i = jResp.SizeOfArray("data");
    while (i < count_i) {
        jResp.put_I(i);
        code = jResp.stringOf("data[i].code");
        Id = jResp.stringOf("data[i].details.id");
        message = jResp.stringOf("data[i].message");
        status = jResp.stringOf("data[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 POST
	-H "Authorization: Bearer <access_token>"
	-d '{
    "data": [
        {
            "id": "{{record_id1}}",
            "Territories": [
                {
                    "id": "{{territory_id1}}"
                },
                {
                    "id": "{{territory_id2}}"
                }
            ]
        },
        {
            "id": "{{record_id2}}",
            "Territories": [
                {
                    "id": "{{territory_id1}}"
                },
                {
                    "id": "{{territory_id2}}"
                }
            ]
        }
    ]
}'
https://domain.com/crm/v2.1/Accounts/actions/assign_territories

Postman Collection Item JSON

{
  "name": "Assign Territories",
  "request": {
    "auth": {
      "type": "bearer",
      "bearer": [
        {
          "key": "token",
          "value": "{{access-token}}",
          "type": "string"
        }
      ]
    },
    "method": "POST",
    "header": [
    ],
    "body": {
      "mode": "raw",
      "raw": "{\n    \"data\": [\n        {\n            \"id\": \"{{record_id1}}\",\n            \"Territories\": [\n                {\n                    \"id\": \"{{territory_id1}}\"\n                },\n                {\n                    \"id\": \"{{territory_id2}}\"\n                }\n            ]\n        },\n        {\n            \"id\": \"{{record_id2}}\",\n            \"Territories\": [\n                {\n                    \"id\": \"{{territory_id1}}\"\n                },\n                {\n                    \"id\": \"{{territory_id2}}\"\n                }\n            ]\n        }\n    ]\n}",
      "options": {
        "raw": {
          "language": "json"
        }
      }
    },
    "url": {
      "raw": "{{api-domain}}/crm/v2.1/Accounts/actions/assign_territories",
      "host": [
        "{{api-domain}}"
      ],
      "path": [
        "crm",
        "v2.1",
        "Accounts",
        "actions",
        "assign_territories"
      ]
    },
    "description": "To assign territories to multiple records or a single record."
  },
  "response": [
    {
      "name": "SUCCESS RESPONSE",
      "originalRequest": {
        "method": "POST",
        "header": [
        ],
        "body": {
          "mode": "raw",
          "raw": "{\n    \"data\": [\n        {\n            \"id\": \"4150868000004818104\",\n            \"Territories\": [\n                {\n                    \"id\": \"4150868000003259003\"\n                },\n                {\n                    \"id\": \"4150868000001390007\"\n                }\n            ]\n        },\n        {\n            \"id\": \"4150868000004818029\",\n            \"Territories\": [\n                {\n                    \"id\": \"4150868000003259003\"\n                },\n                {\n                    \"id\": \"4150868000001390007\"\n                }\n            ]\n        }\n    ]\n}",
          "options": {
            "raw": {
              "language": "json"
            }
          }
        },
        "url": {
          "raw": "{{api-domain}}/crm/v2.1/Contacts/actions/assign_territories",
          "host": [
            "{{api-domain}}"
          ],
          "path": [
            "crm",
            "v2.1",
            "Contacts",
            "actions",
            "assign_territories"
          ]
        }
      },
      "status": "OK",
      "code": 200,
      "_postman_previewlanguage": "json",
      "header": [
        {
          "key": "Server",
          "value": "ZGS"
        },
        {
          "key": "Date",
          "value": "Mon, 03 May 2021 10:35:25 GMT"
        },
        {
          "key": "Content-Type",
          "value": "application/json;charset=utf-8"
        },
        {
          "key": "Content-Length",
          "value": "272"
        },
        {
          "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": "Set-Cookie",
          "value": "listview_enabled=true;Path=/"
        },
        {
          "key": "X-ACCESSTOKEN-RESET",
          "value": "2021-05-03T16:58:36+05:30"
        },
        {
          "key": "clientVersion",
          "value": "4000204"
        },
        {
          "key": "clientsubVersion",
          "value": "9875f452294f1c73e02cebb497ee077e"
        },
        {
          "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    \"data\": [\n        {\n            \"code\": \"SUCCESS\",\n            \"details\": {\n                \"id\": \"4150868000004818104\"\n            },\n            \"message\": \"the territories data updated successfully\",\n            \"status\": \"success\"\n        },\n        {\n            \"code\": \"SUCCESS\",\n            \"details\": {\n                \"id\": \"4150868000004818029\"\n            },\n            \"message\": \"the territories data updated successfully\",\n            \"status\": \"success\"\n        }\n    ]\n}"
    },
    {
      "name": "INVALID_REQUEST_METHOD",
      "originalRequest": {
        "method": "GET",
        "header": [
        ],
        "body": {
          "mode": "raw",
          "raw": "{\n    \"data\": [\n        {\n            \"id\": \"4150868000002492026\",\n            \"Territories\": [\n                {\n                    \"id\": \"4150868000005232029\"\n                },\n                {\n                    \"id\": \"4150868000005232023\"\n                }\n            ]\n        },\n        {\n            \"id\": \"4150868000002492050\",\n            \"Territories\": [\n                {\n                    \"id\": \"4150868000005232029\"\n                },\n                {\n                    \"id\": \"4150868000005232023\"\n                }\n            ]\n        }\n    ]\n}",
          "options": {
            "raw": {
              "language": "json"
            }
          }
        },
        "url": {
          "raw": "{{api-domain}}/crm/v2.1/Accounts/actions/assign_territories",
          "host": [
            "{{api-domain}}"
          ],
          "path": [
            "crm",
            "v2.1",
            "Accounts",
            "actions",
            "assign_territories"
          ]
        }
      },
      "status": "Bad Request",
      "code": 400,
      "_postman_previewlanguage": "json",
      "header": [
        {
          "key": "Server",
          "value": "ZGS"
        },
        {
          "key": "Date",
          "value": "Mon, 03 May 2021 10:14:35 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": "INVALID_DATA (Record ID)",
      "originalRequest": {
        "method": "POST",
        "header": [
        ],
        "body": {
          "mode": "raw",
          "raw": "{\n    \"data\": [\n        {\n            \"id\": \"41508680000024920\",\n            \"Territories\": [\n                {\n                    \"id\": \"4150868000005232029\"\n                },\n                {\n                    \"id\": \"4150868000005232023\"\n                }\n            ]\n        },\n        {\n            \"id\": \"41508680000024920506\",\n            \"Territories\": [\n                {\n                    \"id\": \"4150868000005232029\"\n                },\n                {\n                    \"id\": \"4150868000005232023\"\n                }\n            ]\n        }\n    ]\n}",
          "options": {
            "raw": {
              "language": "json"
            }
          }
        },
        "url": {
          "raw": "{{api-domain}}/crm/v2.1/Accounts/actions/assign_territories",
          "host": [
            "{{api-domain}}"
          ],
          "path": [
            "crm",
            "v2.1",
            "Accounts",
            "actions",
            "assign_territories"
          ]
        }
      },
      "status": "Bad Request",
      "code": 400,
      "_postman_previewlanguage": "json",
      "header": [
        {
          "key": "Server",
          "value": "ZGS"
        },
        {
          "key": "Date",
          "value": "Mon, 03 May 2021 10:17:48 GMT"
        },
        {
          "key": "Content-Type",
          "value": "application/json;charset=utf-8"
        },
        {
          "key": "Content-Length",
          "value": "309"
        },
        {
          "key": "Connection",
          "value": "keep-alive"
        },
        {
          "key": "Set-Cookie",
          "value": "1a99390653=12a340a9c5d3e8d49c85c68bd2161d0b; Path=/"
        },
        {
          "key": "Set-Cookie",
          "value": "crmcsr=2c37198e-ea63-4e3c-bcee-b4adda5d60a2;path=/;SameSite=None;Secure;priority=high"
        },
        {
          "key": "Set-Cookie",
          "value": "_zcsr_tmp=2c37198e-ea63-4e3c-bcee-b4adda5d60a2;path=/;SameSite=Strict;Secure;priority=high"
        },
        {
          "key": "Set-Cookie",
          "value": "listview_enabled=true;Path=/"
        },
        {
          "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-03T15:57:57+05:30"
        },
        {
          "key": "clientVersion",
          "value": "4000204"
        },
        {
          "key": "clientsubVersion",
          "value": "9875f452294f1c73e02cebb497ee077e"
        },
        {
          "key": "Content-Disposition",
          "value": "attachment; filename=response.json"
        },
        {
          "key": "Content-Language",
          "value": "en-US"
        }
      ],
      "cookie": [
      ],
      "body": "{\n    \"data\": [\n        {\n            \"code\": \"INVALID_DATA\",\n            \"details\": {\n                \"api_name\": \"id\",\n                \"json_path\": \"$.data[0].id\"\n            },\n            \"message\": \"The record Id given seems to be invalid\",\n            \"status\": \"error\"\n        },\n        {\n            \"code\": \"INVALID_DATA\",\n            \"details\": {\n                \"expected_data_type\": \"bigint\",\n                \"api_name\": \"id\",\n                \"json_path\": \"$.data[1].id\"\n            },\n            \"message\": \"invalid data\",\n            \"status\": \"error\"\n        }\n    ]\n}"
    },
    {
      "name": "INVALID_DATA (Territory ID)",
      "originalRequest": {
        "method": "POST",
        "header": [
        ],
        "body": {
          "mode": "raw",
          "raw": "{\n    \"data\": [\n        {\n            \"id\": \"4150868000002492075\",\n            \"Territories\": [\n                {\n                    \"id\": \"415086800000523202\"\n                },\n                {\n                    \"id\": \"4150868000005232023\"\n                }\n            ]\n        }\n    ]\n}",
          "options": {
            "raw": {
              "language": "json"
            }
          }
        },
        "url": {
          "raw": "{{api-domain}}/crm/v2.1/Accounts/actions/assign_territories",
          "host": [
            "{{api-domain}}"
          ],
          "path": [
            "crm",
            "v2.1",
            "Accounts",
            "actions",
            "assign_territories"
          ]
        }
      },
      "status": "Bad Request",
      "code": 400,
      "_postman_previewlanguage": "json",
      "header": [
        {
          "key": "Server",
          "value": "ZGS"
        },
        {
          "key": "Date",
          "value": "Mon, 03 May 2021 10:20:59 GMT"
        },
        {
          "key": "Content-Type",
          "value": "application/json;charset=utf-8"
        },
        {
          "key": "Content-Length",
          "value": "166"
        },
        {
          "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": "Set-Cookie",
          "value": "listview_enabled=true;Path=/"
        },
        {
          "key": "X-ACCESSTOKEN-RESET",
          "value": "2021-05-03T15:57:57+05:30"
        },
        {
          "key": "clientVersion",
          "value": "4000204"
        },
        {
          "key": "clientsubVersion",
          "value": "9875f452294f1c73e02cebb497ee077e"
        },
        {
          "key": "Content-Disposition",
          "value": "attachment; filename=response.json"
        },
        {
          "key": "Content-Language",
          "value": "en-US"
        }
      ],
      "cookie": [
      ],
      "body": "{\n    \"data\": [\n        {\n            \"code\": \"INVALID_DATA\",\n            \"details\": {\n                \"api_name\": \"id\",\n                \"json_path\": \"$.data[0].Territories[0].id\"\n            },\n            \"message\": \"the id given seems to be invalid\",\n            \"status\": \"error\"\n        }\n    ]\n}"
    },
    {
      "name": "MULTI-STATUS ERROR",
      "originalRequest": {
        "method": "POST",
        "header": [
        ],
        "body": {
          "mode": "raw",
          "raw": "{\n    \"data\": [\n        {\n            \"id\": \"41508680000024920\",\n            \"Territories\": [\n                {\n                    \"id\": \"415086800000278200\"\n                },\n                {\n                    \"id\": \"4150868000005232023\"\n                }\n            ]\n        },\n        {\n            \"id\": \"4150868000002492075\",\n            \"Territories\": [\n                {\n                    \"id\": \"4150868000005232029\"\n                },\n                {\n                    \"id\": \"4150868000005232023\"\n                }\n            ]\n        }\n    ]\n}",
          "options": {
            "raw": {
              "language": "json"
            }
          }
        },
        "url": {
          "raw": "{{api-domain}}/crm/v2.1/Accounts/actions/assign_territories",
          "host": [
            "{{api-domain}}"
          ],
          "path": [
            "crm",
            "v2.1",
            "Accounts",
            "actions",
            "assign_territories"
          ]
        }
      },
      "status": "Multi-Status (WebDAV) (RFC 4918)",
      "code": 207,
      "_postman_previewlanguage": "json",
      "header": [
        {
          "key": "Server",
          "value": "ZGS"
        },
        {
          "key": "Date",
          "value": "Mon, 03 May 2021 10:19:37 GMT"
        },
        {
          "key": "Content-Type",
          "value": "application/json;charset=utf-8"
        },
        {
          "key": "Content-Length",
          "value": "289"
        },
        {
          "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": "Set-Cookie",
          "value": "listview_enabled=true;Path=/"
        },
        {
          "key": "X-ACCESSTOKEN-RESET",
          "value": "2021-05-03T15:57:57+05:30"
        },
        {
          "key": "clientVersion",
          "value": "4000204"
        },
        {
          "key": "clientsubVersion",
          "value": "9875f452294f1c73e02cebb497ee077e"
        },
        {
          "key": "Content-Disposition",
          "value": "attachment; filename=response.json"
        },
        {
          "key": "Content-Language",
          "value": "en-US"
        }
      ],
      "cookie": [
      ],
      "body": "{\n    \"data\": [\n        {\n            \"code\": \"INVALID_DATA\",\n            \"details\": {\n                \"api_name\": \"id\",\n                \"json_path\": \"$.data[0].id\"\n            },\n            \"message\": \"The record Id given seems to be invalid\",\n            \"status\": \"error\"\n        },\n        {\n            \"code\": \"SUCCESS\",\n            \"details\": {\n                \"id\": \"4150868000002492075\"\n            },\n            \"message\": \"the territories data updated successfully\",\n            \"status\": \"success\"\n        }\n    ]\n}"
    },
    {
      "name": "MANDATORY_NOT_FOUND (Record ID)",
      "originalRequest": {
        "method": "POST",
        "header": [
        ],
        "body": {
          "mode": "raw",
          "raw": "{\n    \"data\": [\n        {\n            \"Territories\": [\n                {\n                    \"id\": \"415086800000523202\"\n                },\n                {\n                    \"id\": \"4150868000005232023\"\n                }\n            ]\n        }\n    ]\n}",
          "options": {
            "raw": {
              "language": "json"
            }
          }
        },
        "url": {
          "raw": "{{api-domain}}/crm/v2.1/Accounts/actions/assign_territories",
          "host": [
            "{{api-domain}}"
          ],
          "path": [
            "crm",
            "v2.1",
            "Accounts",
            "actions",
            "assign_territories"
          ]
        }
      },
      "status": "Bad Request",
      "code": 400,
      "_postman_previewlanguage": "json",
      "header": [
        {
          "key": "Server",
          "value": "ZGS"
        },
        {
          "key": "Date",
          "value": "Mon, 03 May 2021 10:21:57 GMT"
        },
        {
          "key": "Content-Type",
          "value": "application/json;charset=utf-8"
        },
        {
          "key": "Content-Length",
          "value": "166"
        },
        {
          "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": "Set-Cookie",
          "value": "listview_enabled=true;Path=/"
        },
        {
          "key": "X-ACCESSTOKEN-RESET",
          "value": "2021-05-03T15:57:57+05:30"
        },
        {
          "key": "clientVersion",
          "value": "4000204"
        },
        {
          "key": "clientsubVersion",
          "value": "9875f452294f1c73e02cebb497ee077e"
        },
        {
          "key": "Content-Disposition",
          "value": "attachment; filename=response.json"
        },
        {
          "key": "Content-Language",
          "value": "en-US"
        }
      ],
      "cookie": [
      ],
      "body": "{\n    \"data\": [\n        {\n            \"code\": \"MANDATORY_NOT_FOUND\",\n            \"details\": {\n                \"api_name\": \"id\",\n                \"json_path\": \"$.data[0].id\"\n            },\n            \"message\": \"One of the expected parameter is missing\",\n            \"status\": \"error\"\n        }\n    ]\n}"
    },
    {
      "name": "MANDATORY_NOT_FOUND (Territory ID)",
      "originalRequest": {
        "method": "POST",
        "header": [
        ],
        "body": {
          "mode": "raw",
          "raw": "{\n    \"data\": [\n        {\n            \"id\": \"4150868000002492075\",\n            \"Territories\": []\n        }\n    ]\n}",
          "options": {
            "raw": {
              "language": "json"
            }
          }
        },
        "url": {
          "raw": "{{api-domain}}/crm/v2.1/Accounts/actions/assign_territories",
          "host": [
            "{{api-domain}}"
          ],
          "path": [
            "crm",
            "v2.1",
            "Accounts",
            "actions",
            "assign_territories"
          ]
        }
      },
      "status": "Bad Request",
      "code": 400,
      "_postman_previewlanguage": "json",
      "header": [
        {
          "key": "Server",
          "value": "ZGS"
        },
        {
          "key": "Date",
          "value": "Mon, 03 May 2021 10:22:49 GMT"
        },
        {
          "key": "Content-Type",
          "value": "application/json;charset=utf-8"
        },
        {
          "key": "Content-Length",
          "value": "168"
        },
        {
          "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": "Set-Cookie",
          "value": "listview_enabled=true;Path=/"
        },
        {
          "key": "X-ACCESSTOKEN-RESET",
          "value": "2021-05-03T15:57:57+05:30"
        },
        {
          "key": "clientVersion",
          "value": "4000204"
        },
        {
          "key": "clientsubVersion",
          "value": "9875f452294f1c73e02cebb497ee077e"
        },
        {
          "key": "Content-Disposition",
          "value": "attachment; filename=response.json"
        },
        {
          "key": "Content-Language",
          "value": "en-US"
        }
      ],
      "cookie": [
      ],
      "body": "{\n    \"data\": [\n        {\n            \"code\": \"MANDATORY_NOT_FOUND\",\n            \"details\": {\n                \"api_name\": \"Territories\",\n                \"json_path\": \"$.data[0].Territories\"\n            },\n            \"message\": \"required field not found\",\n            \"status\": \"error\"\n        }\n    ]\n}"
    },
    {
      "name": "ALREADY_USED",
      "originalRequest": {
        "method": "POST",
        "header": [
        ],
        "body": {
          "mode": "raw",
          "raw": "{\n    \"data\": [\n        {\n            \"id\": \"4150868000002492075\",\n            \"Territories\": [\n                {\n                    \"id\": \"4150868000004822544\"\n                },\n                {\n                    \"id\": \"4150868000004822544\"\n                }\n            ]\n        }\n    ]\n}",
          "options": {
            "raw": {
              "language": "json"
            }
          }
        },
        "url": {
          "raw": "{{api-domain}}/crm/v2.1/Accounts/actions/assign_territories",
          "host": [
            "{{api-domain}}"
          ],
          "path": [
            "crm",
            "v2.1",
            "Accounts",
            "actions",
            "assign_territories"
          ]
        }
      },
      "status": "Bad Request",
      "code": 400,
      "_postman_previewlanguage": "json",
      "header": [
        {
          "key": "Server",
          "value": "ZGS"
        },
        {
          "key": "Date",
          "value": "Mon, 03 May 2021 10:24:03 GMT"
        },
        {
          "key": "Content-Type",
          "value": "application/json;charset=utf-8"
        },
        {
          "key": "Content-Length",
          "value": "162"
        },
        {
          "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": "Set-Cookie",
          "value": "listview_enabled=true;Path=/"
        },
        {
          "key": "X-ACCESSTOKEN-RESET",
          "value": "2021-05-03T15:57:57+05:30"
        },
        {
          "key": "clientVersion",
          "value": "4000204"
        },
        {
          "key": "clientsubVersion",
          "value": "9875f452294f1c73e02cebb497ee077e"
        },
        {
          "key": "Content-Disposition",
          "value": "attachment; filename=response.json"
        },
        {
          "key": "Content-Language",
          "value": "en-US"
        }
      ],
      "cookie": [
      ],
      "body": "{\n    \"data\": [\n        {\n            \"code\": \"ALREADY_USED\",\n            \"details\": {\n                \"api_name\": \"id\",\n                \"json_path\": \"$.data[0].Territories[1].id\"\n            },\n            \"message\": \"duplicate territory id found\",\n            \"status\": \"error\"\n        }\n    ]\n}"
    },
    {
      "name": "DUPLICATE_DATA",
      "originalRequest": {
        "method": "POST",
        "header": [
        ],
        "body": {
          "mode": "raw",
          "raw": "{\n    \"data\": [\n        {\n            \"id\": \"4150868000002492075\",\n            \"Territories\": [\n                {\n                    \"id\": \"4150868000004822544\"\n                },\n                {\n                    \"id\": \"4150868000000236307\"\n                }\n            ]\n        }\n    ]\n}",
          "options": {
            "raw": {
              "language": "json"
            }
          }
        },
        "url": {
          "raw": "{{api-domain}}/crm/v2.1/Accounts/actions/assign_territories",
          "host": [
            "{{api-domain}}"
          ],
          "path": [
            "crm",
            "v2.1",
            "Accounts",
            "actions",
            "assign_territories"
          ]
        }
      },
      "status": "Bad Request",
      "code": 400,
      "_postman_previewlanguage": "json",
      "header": [
        {
          "key": "Server",
          "value": "ZGS"
        },
        {
          "key": "Date",
          "value": "Mon, 03 May 2021 10:25:13 GMT"
        },
        {
          "key": "Content-Type",
          "value": "application/json;charset=utf-8"
        },
        {
          "key": "Content-Length",
          "value": "185"
        },
        {
          "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": "Set-Cookie",
          "value": "listview_enabled=true;Path=/"
        },
        {
          "key": "X-ACCESSTOKEN-RESET",
          "value": "2021-05-03T15:57:57+05:30"
        },
        {
          "key": "clientVersion",
          "value": "4000204"
        },
        {
          "key": "clientsubVersion",
          "value": "9875f452294f1c73e02cebb497ee077e"
        },
        {
          "key": "Content-Disposition",
          "value": "attachment; filename=response.json"
        },
        {
          "key": "Content-Language",
          "value": "en-US"
        }
      ],
      "cookie": [
      ],
      "body": "{\n    \"data\": [\n        {\n            \"code\": \"DUPLICATE_DATA\",\n            \"details\": {\n                \"api_name\": \"id\",\n                \"json_path\": \"$.data[0].Territories[0].id\"\n            },\n            \"message\": \"Given Territory id already exists for that record\",\n            \"status\": \"error\"\n        }\n    ]\n}"
    },
    {
      "name": "AUTHENTICATION_FAILURE",
      "originalRequest": {
        "method": "POST",
        "header": [
        ],
        "body": {
          "mode": "raw",
          "raw": "{\n    \"data\": [\n        {\n            \"id\": \"4150868000002492075\",\n            \"Territories\": [\n                {\n                    \"id\": \"4150868000004822544\"\n                },\n                {\n                    \"id\": \"4150868000000236307\"\n                }\n            ]\n        }\n    ]\n}",
          "options": {
            "raw": {
              "language": "json"
            }
          }
        },
        "url": {
          "raw": "{{api-domain}}/crm/v2.1/Accounts/actions/assign_territories",
          "host": [
            "{{api-domain}}"
          ],
          "path": [
            "crm",
            "v2.1",
            "Accounts",
            "actions",
            "assign_territories"
          ]
        }
      },
      "status": "Unauthorized",
      "code": 401,
      "_postman_previewlanguage": "json",
      "header": [
        {
          "key": "Server",
          "value": "ZGS"
        },
        {
          "key": "Date",
          "value": "Mon, 03 May 2021 10:25:39 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": "OAUTH_SCOPE_MISMATCH",
      "originalRequest": {
        "method": "POST",
        "header": [
        ],
        "body": {
          "mode": "raw",
          "raw": "{\n    \"data\": [\n        {\n            \"id\": \"4150868000002492075\",\n            \"Territories\": [\n                {\n                    \"id\": \"4150868000004822544\"\n                },\n                {\n                    \"id\": \"4150868000000236307\"\n                }\n            ]\n        }\n    ]\n}",
          "options": {
            "raw": {
              "language": "json"
            }
          }
        },
        "url": {
          "raw": "{{api-domain}}/crm/v2.1/Accounts/actions/assign_territories",
          "host": [
            "{{api-domain}}"
          ],
          "path": [
            "crm",
            "v2.1",
            "Accounts",
            "actions",
            "assign_territories"
          ]
        }
      },
      "status": "Unauthorized",
      "code": 401,
      "_postman_previewlanguage": "json",
      "header": [
        {
          "key": "Server",
          "value": "ZGS"
        },
        {
          "key": "Date",
          "value": "Mon, 03 May 2021 10:26:35 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}"
    }
  ]
}