Chilkat Online Tools

Java / Zoho CRM REST APIs / Products

Back to Collection Items

import com.chilkatsoft.*;

public class ChilkatExample {

  static {
    try {
        System.loadLibrary("chilkat");
    } catch (UnsatisfiedLinkError e) {
      System.err.println("Native code library failed to load.\n" + e);
      System.exit(1);
    }
  }

  public static void main(String argv[])
  {
    // 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.

    // {
    //   "tags": [
    //     {
    //       "name": "middleware"
    //     },
    //     {
    //       "name": "OS"
    //     }
    //   ]
    // }

    CkJsonObject json = new CkJsonObject();
    json.UpdateString("tags[0].name","middleware");
    json.UpdateString("tags[1].name","OS");

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

    CkHttpResponse resp = http.PostJson3("https://domain.com/crm/v2/settings/tags?module=Products","application/json",json);
    if (http.get_LastMethodSuccess() == false) {
        System.out.println(http.lastErrorText());
        return;
        }

    System.out.println(resp.get_StatusCode());
    System.out.println(resp.bodyStr());
  }
}

Curl Command

curl -X POST
	-H "Authorization: Bearer <access_token>"
	-d '{
    "tags": [
        {
            "name": "middleware"
        },
        {
            "name": "OS"
        }
    ]
}'
https://domain.com/crm/v2/settings/tags?module=Products

Postman Collection Item JSON

{
  "name": "Products",
  "request": {
    "auth": {
      "type": "bearer",
      "bearer": [
        {
          "key": "token",
          "value": "{{access-token}}",
          "type": "string"
        }
      ]
    },
    "method": "POST",
    "header": [
    ],
    "body": {
      "mode": "raw",
      "raw": "{\n    \"tags\": [\n        {\n            \"name\": \"middleware\"\n        },\n        {\n            \"name\": \"OS\"\n        }\n    ]\n}",
      "options": {
        "raw": {
          "language": "json"
        }
      }
    },
    "url": {
      "raw": "{{api-domain}}/crm/v2/settings/tags?module=Products",
      "host": [
        "{{api-domain}}"
      ],
      "path": [
        "crm",
        "v2",
        "settings",
        "tags"
      ],
      "query": [
        {
          "key": "module",
          "value": "Products"
        }
      ]
    },
    "description": "To create new tags."
  },
  "response": [
  ]
}