Chilkat Online Tools

Java / Support API / List Trigger Revisions

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;

    http.put_BasicAuth(true);
    http.put_Login("login");
    http.put_Password("password");

    http.SetRequestHeader("Accept","application/json");

    CkStringBuilder sbResponseBody = new CkStringBuilder();
    success = http.QuickGetSb("https://example.zendesk.com/api/v2/triggers/:trigger_id/revisions",sbResponseBody);
    if (success == false) {
        System.out.println(http.lastErrorText());
        return;
        }

    CkJsonObject jResp = new CkJsonObject();
    jResp.LoadSb(sbResponseBody);
    jResp.put_EmitCompact(false);

    System.out.println("Response Body:");
    System.out.println(jResp.emit());

    int respStatusCode = http.get_LastStatus();
    System.out.println("Response Status Code = " + respStatusCode);
    if (respStatusCode >= 400) {
        System.out.println("Response Header:");
        System.out.println(http.lastHeader());
        System.out.println("Failed.");
        return;
        }

    // Sample JSON response:
    // (Sample code for parsing the JSON response is shown below)

    // {
    //   "after_cursor": "<string>",
    //   "after_url": "<string>",
    //   "before_cursor": "<string>",
    //   "before_url": "<string>",
    //   "count": "<integer>",
    //   "trigger_revisions": [
    //     {
    //       "author_id": "<integer>",
    //       "created_at": "<string>",
    //       "diff": {
    //         "actions": [
    //           {
    //             "field": [
    //               {
    //                 "change": "<string>",
    //                 "content": "<boolean>"
    //               },
    //               {
    //                 "change": "<string>",
    //                 "content": "<boolean>"
    //               }
    //             ],
    //             "value": [
    //               {
    //                 "change": "<string>",
    //                 "content": "<boolean>"
    //               },
    //               {
    //                 "change": "<string>",
    //                 "content": "<boolean>"
    //               }
    //             ]
    //           },
    //           {
    //             "field": [
    //               {
    //                 "change": "<string>",
    //                 "content": "<boolean>"
    //               },
    //               {
    //                 "change": "<string>",
    //                 "content": "<boolean>"
    //               }
    //             ],
    //             "value": [
    //               {
    //                 "change": "<string>",
    //                 "content": "<boolean>"
    //               },
    //               {
    //                 "change": "<string>",
    //                 "content": "<boolean>"
    //               }
    //             ]
    //           }
    //         ],
    //         "active": [
    //           {
    //             "change": "<string>",
    //             "content": "<boolean>"
    //           },
    //           {
    //             "change": "<string>",
    //             "content": "<boolean>"
    //           }
    //         ],
    //         "conditions": {
    //           "field": [
    //             {
    //               "change": "<string>",
    //               "content": "<boolean>"
    //             },
    //             {
    //               "change": "<string>",
    //               "content": "<boolean>"
    //             }
    //           ],
    //           "operator": [
    //             {
    //               "change": "<string>",
    //               "content": "<boolean>"
    //             },
    //             {
    //               "change": "<string>",
    //               "content": "<boolean>"
    //             }
    //           ],
    //           "value": [
    //             {
    //               "change": "<string>",
    //               "content": "<boolean>"
    //             },
    //             {
    //               "change": "<string>",
    //               "content": "<boolean>"
    //             }
    //           ]
    //         },
    //         "description": [
    //           {
    //             "change": "<string>",
    //             "content": "<boolean>"
    //           },
    //           {
    //             "change": "<string>",
    //             "content": "<boolean>"
    //           }
    //         ],
    //         "source_id": "<integer>",
    //         "target_id": "<integer>",
    //         "title": [
    //           {
    //             "change": "<string>",
    //             "content": "<boolean>"
    //           },
    //           {
    //             "change": "<string>",
    //             "content": "<boolean>"
    //           }
    //         ]
    //       },
    //       "id": "<integer>",
    //       "snapshot": {
    //         "actions": [
    //           {
    //             "field": "<string>",
    //             "value": "<string>"
    //           },
    //           {
    //             "field": "<string>",
    //             "value": "<string>"
    //           }
    //         ],
    //         "active": "<boolean>",
    //         "conditions": {
    //           "all": [
    //             {
    //               "field": "<string>",
    //               "operator": "<string>",
    //               "value": "<string>"
    //             },
    //             {
    //               "field": "<string>",
    //               "operator": "<string>",
    //               "value": "<string>"
    //             }
    //           ],
    //           "any": [
    //             {
    //               "field": "<string>",
    //               "operator": "<string>",
    //               "value": "<string>"
    //             },
    //             {
    //               "field": "<string>",
    //               "operator": "<string>",
    //               "value": "<string>"
    //             }
    //           ]
    //         },
    //         "description": "<string>",
    //         "title": "<string>"
    //       },
    //       "url": "<string>"
    //     },
    //     {
    //       "author_id": "<integer>",
    //       "created_at": "<string>",
    //       "diff": {
    //         "actions": [
    //           {
    //             "field": [
    //               {
    //                 "change": "<string>",
    //                 "content": "<boolean>"
    //               },
    //               {
    //                 "change": "<string>",
    //                 "content": "<boolean>"
    //               }
    //             ],
    //             "value": [
    //               {
    //                 "change": "<string>",
    //                 "content": "<boolean>"
    //               },
    //               {
    //                 "change": "<string>",
    //                 "content": "<boolean>"
    //               }
    //             ]
    //           },
    //           {
    //             "field": [
    //               {
    //                 "change": "<string>",
    //                 "content": "<boolean>"
    //               },
    //               {
    //                 "change": "<string>",
    //                 "content": "<boolean>"
    //               }
    //             ],
    //             "value": [
    //               {
    //                 "change": "<string>",
    //                 "content": "<boolean>"
    //               },
    //               {
    //                 "change": "<string>",
    //                 "content": "<boolean>"
    //               }
    //             ]
    //           }
    //         ],
    //         "active": [
    //           {
    //             "change": "<string>",
    //             "content": "<boolean>"
    //           },
    //           {
    //             "change": "<string>",
    //             "content": "<boolean>"
    //           }
    //         ],
    //         "conditions": {
    //           "field": [
    //             {
    //               "change": "<string>",
    //               "content": "<boolean>"
    //             },
    //             {
    //               "change": "<string>",
    //               "content": "<boolean>"
    //             }
    //           ],
    //           "operator": [
    //             {
    //               "change": "<string>",
    //               "content": "<boolean>"
    //             },
    //             {
    //               "change": "<string>",
    //               "content": "<boolean>"
    //             }
    //           ],
    //           "value": [
    //             {
    //               "change": "<string>",
    //               "content": "<boolean>"
    //             },
    //             {
    //               "change": "<string>",
    //               "content": "<boolean>"
    //             }
    //           ]
    //         },
    //         "description": [
    //           {
    //             "change": "<string>",
    //             "content": "<boolean>"
    //           },
    //           {
    //             "change": "<string>",
    //             "content": "<boolean>"
    //           }
    //         ],
    //         "source_id": "<integer>",
    //         "target_id": "<integer>",
    //         "title": [
    //           {
    //             "change": "<string>",
    //             "content": "<boolean>"
    //           },
    //           {
    //             "change": "<string>",
    //             "content": "<boolean>"
    //           }
    //         ]
    //       },
    //       "id": "<integer>",
    //       "snapshot": {
    //         "actions": [
    //           {
    //             "field": "<string>",
    //             "value": "<string>"
    //           },
    //           {
    //             "field": "<string>",
    //             "value": "<string>"
    //           }
    //         ],
    //         "active": "<boolean>",
    //         "conditions": {
    //           "all": [
    //             {
    //               "field": "<string>",
    //               "operator": "<string>",
    //               "value": "<string>"
    //             },
    //             {
    //               "field": "<string>",
    //               "operator": "<string>",
    //               "value": "<string>"
    //             }
    //           ],
    //           "any": [
    //             {
    //               "field": "<string>",
    //               "operator": "<string>",
    //               "value": "<string>"
    //             },
    //             {
    //               "field": "<string>",
    //               "operator": "<string>",
    //               "value": "<string>"
    //             }
    //           ]
    //         },
    //         "description": "<string>",
    //         "title": "<string>"
    //       },
    //       "url": "<string>"
    //     }
    //   ]
    // }

    // Sample code for parsing the JSON response...
    // Use this online tool to generate parsing code from sample JSON: Generate JSON Parsing Code

    String author_id;
    String created_at;
    String Source_id;
    String Target_id;
    String id;
    String Active;
    String Description;
    String Title;
    String url;
    int j;
    int count_j;
    int k;
    int count_k;
    String change;
    String content;
    String field;
    String value;
    String operator;

    String after_cursor = jResp.stringOf("after_cursor");
    String after_url = jResp.stringOf("after_url");
    String before_cursor = jResp.stringOf("before_cursor");
    String before_url = jResp.stringOf("before_url");
    String count = jResp.stringOf("count");
    int i = 0;
    int count_i = jResp.SizeOfArray("trigger_revisions");
    while (i < count_i) {
        jResp.put_I(i);
        author_id = jResp.stringOf("trigger_revisions[i].author_id");
        created_at = jResp.stringOf("trigger_revisions[i].created_at");
        Source_id = jResp.stringOf("trigger_revisions[i].diff.source_id");
        Target_id = jResp.stringOf("trigger_revisions[i].diff.target_id");
        id = jResp.stringOf("trigger_revisions[i].id");
        Active = jResp.stringOf("trigger_revisions[i].snapshot.active");
        Description = jResp.stringOf("trigger_revisions[i].snapshot.description");
        Title = jResp.stringOf("trigger_revisions[i].snapshot.title");
        url = jResp.stringOf("trigger_revisions[i].url");
        j = 0;
        count_j = jResp.SizeOfArray("trigger_revisions[i].diff.actions");
        while (j < count_j) {
            jResp.put_J(j);
            k = 0;
            count_k = jResp.SizeOfArray("trigger_revisions[i].diff.actions[j].field");
            while (k < count_k) {
                jResp.put_K(k);
                change = jResp.stringOf("trigger_revisions[i].diff.actions[j].field[k].change");
                content = jResp.stringOf("trigger_revisions[i].diff.actions[j].field[k].content");
                k = k+1;
                }

            k = 0;
            count_k = jResp.SizeOfArray("trigger_revisions[i].diff.actions[j].value");
            while (k < count_k) {
                jResp.put_K(k);
                change = jResp.stringOf("trigger_revisions[i].diff.actions[j].value[k].change");
                content = jResp.stringOf("trigger_revisions[i].diff.actions[j].value[k].content");
                k = k+1;
                }

            j = j+1;
            }

        j = 0;
        count_j = jResp.SizeOfArray("trigger_revisions[i].diff.active");
        while (j < count_j) {
            jResp.put_J(j);
            change = jResp.stringOf("trigger_revisions[i].diff.active[j].change");
            content = jResp.stringOf("trigger_revisions[i].diff.active[j].content");
            j = j+1;
            }

        j = 0;
        count_j = jResp.SizeOfArray("trigger_revisions[i].diff.conditions.field");
        while (j < count_j) {
            jResp.put_J(j);
            change = jResp.stringOf("trigger_revisions[i].diff.conditions.field[j].change");
            content = jResp.stringOf("trigger_revisions[i].diff.conditions.field[j].content");
            j = j+1;
            }

        j = 0;
        count_j = jResp.SizeOfArray("trigger_revisions[i].diff.conditions.operator");
        while (j < count_j) {
            jResp.put_J(j);
            change = jResp.stringOf("trigger_revisions[i].diff.conditions.operator[j].change");
            content = jResp.stringOf("trigger_revisions[i].diff.conditions.operator[j].content");
            j = j+1;
            }

        j = 0;
        count_j = jResp.SizeOfArray("trigger_revisions[i].diff.conditions.value");
        while (j < count_j) {
            jResp.put_J(j);
            change = jResp.stringOf("trigger_revisions[i].diff.conditions.value[j].change");
            content = jResp.stringOf("trigger_revisions[i].diff.conditions.value[j].content");
            j = j+1;
            }

        j = 0;
        count_j = jResp.SizeOfArray("trigger_revisions[i].diff.description");
        while (j < count_j) {
            jResp.put_J(j);
            change = jResp.stringOf("trigger_revisions[i].diff.description[j].change");
            content = jResp.stringOf("trigger_revisions[i].diff.description[j].content");
            j = j+1;
            }

        j = 0;
        count_j = jResp.SizeOfArray("trigger_revisions[i].diff.title");
        while (j < count_j) {
            jResp.put_J(j);
            change = jResp.stringOf("trigger_revisions[i].diff.title[j].change");
            content = jResp.stringOf("trigger_revisions[i].diff.title[j].content");
            j = j+1;
            }

        j = 0;
        count_j = jResp.SizeOfArray("trigger_revisions[i].snapshot.actions");
        while (j < count_j) {
            jResp.put_J(j);
            field = jResp.stringOf("trigger_revisions[i].snapshot.actions[j].field");
            value = jResp.stringOf("trigger_revisions[i].snapshot.actions[j].value");
            j = j+1;
            }

        j = 0;
        count_j = jResp.SizeOfArray("trigger_revisions[i].snapshot.conditions.all");
        while (j < count_j) {
            jResp.put_J(j);
            field = jResp.stringOf("trigger_revisions[i].snapshot.conditions.all[j].field");
            operator = jResp.stringOf("trigger_revisions[i].snapshot.conditions.all[j].operator");
            value = jResp.stringOf("trigger_revisions[i].snapshot.conditions.all[j].value");
            j = j+1;
            }

        j = 0;
        count_j = jResp.SizeOfArray("trigger_revisions[i].snapshot.conditions.any");
        while (j < count_j) {
            jResp.put_J(j);
            field = jResp.stringOf("trigger_revisions[i].snapshot.conditions.any[j].field");
            operator = jResp.stringOf("trigger_revisions[i].snapshot.conditions.any[j].operator");
            value = jResp.stringOf("trigger_revisions[i].snapshot.conditions.any[j].value");
            j = j+1;
            }

        i = i+1;
        }
  }
}

Curl Command

curl  -u login:password -X GET
	-H "Accept: application/json"
https://example.zendesk.com/api/v2/triggers/:trigger_id/revisions

Postman Collection Item JSON

{
  "name": "List Trigger Revisions",
  "request": {
    "method": "GET",
    "header": [
      {
        "key": "Accept",
        "value": "application/json"
      }
    ],
    "url": {
      "raw": "{{baseUrl}}/api/v2/triggers/:trigger_id/revisions",
      "host": [
        "{{baseUrl}}"
      ],
      "path": [
        "api",
        "v2",
        "triggers",
        ":trigger_id",
        "revisions"
      ],
      "variable": [
        {
          "key": "trigger_id",
          "value": "<integer>"
        }
      ]
    },
    "description": "List the revisions associated with a trigger. Trigger revision history is only available on Enterprise plans.\n\n#### Allowed For\n\n * Agents\n\n#### Sideloads\n\nThe following sideloads are supported:\n\n| Name  | Will sideload\n| ----- | -------------\n| users | The user that authored each revision\n\n#### Pagination\n\nThis endpoint uses cursor-based pagination. The records are ordered in\ndescending order by the `created_at` timestamp, then by `id` on duplicate\n`created_at` values.\n\nThe `cursor` parameter is a non-human-readable argument you can use to move\nforward or backward in time.\n\nEach JSON response will contain the following attributes to help you get\nmore results:\n\n- `after_url` requests more recent results\n- `before_url` requests older results\n- `after_cursor` is the cursor to build the request yourself\n- `before_cursor` is the cursor to build the request yourself\n\nThe properties are null if no more records are available.\n\nYou can request a maximum of 1000 records using the `limit` parameter. If\nno `limit` parameter is supplied, it will default to 1,000.\n"
  },
  "response": [
    {
      "name": "Success response",
      "originalRequest": {
        "method": "GET",
        "header": [
          {
            "description": "Added as a part of security scheme: basic",
            "key": "Authorization",
            "value": "Basic <credentials>"
          }
        ],
        "url": {
          "raw": "{{baseUrl}}/api/v2/triggers/:trigger_id/revisions",
          "host": [
            "{{baseUrl}}"
          ],
          "path": [
            "api",
            "v2",
            "triggers",
            ":trigger_id",
            "revisions"
          ],
          "variable": [
            {
              "key": "trigger_id"
            }
          ]
        }
      },
      "status": "OK",
      "code": 200,
      "_postman_previewlanguage": "json",
      "header": [
        {
          "key": "Content-Type",
          "value": "application/json"
        }
      ],
      "cookie": [
      ],
      "body": "{\n  \"after_cursor\": \"<string>\",\n  \"after_url\": \"<string>\",\n  \"before_cursor\": \"<string>\",\n  \"before_url\": \"<string>\",\n  \"count\": \"<integer>\",\n  \"trigger_revisions\": [\n    {\n      \"author_id\": \"<integer>\",\n      \"created_at\": \"<string>\",\n      \"diff\": {\n        \"actions\": [\n          {\n            \"field\": [\n              {\n                \"change\": \"<string>\",\n                \"content\": \"<boolean>\"\n              },\n              {\n                \"change\": \"<string>\",\n                \"content\": \"<boolean>\"\n              }\n            ],\n            \"value\": [\n              {\n                \"change\": \"<string>\",\n                \"content\": \"<boolean>\"\n              },\n              {\n                \"change\": \"<string>\",\n                \"content\": \"<boolean>\"\n              }\n            ]\n          },\n          {\n            \"field\": [\n              {\n                \"change\": \"<string>\",\n                \"content\": \"<boolean>\"\n              },\n              {\n                \"change\": \"<string>\",\n                \"content\": \"<boolean>\"\n              }\n            ],\n            \"value\": [\n              {\n                \"change\": \"<string>\",\n                \"content\": \"<boolean>\"\n              },\n              {\n                \"change\": \"<string>\",\n                \"content\": \"<boolean>\"\n              }\n            ]\n          }\n        ],\n        \"active\": [\n          {\n            \"change\": \"<string>\",\n            \"content\": \"<boolean>\"\n          },\n          {\n            \"change\": \"<string>\",\n            \"content\": \"<boolean>\"\n          }\n        ],\n        \"conditions\": {\n          \"field\": [\n            {\n              \"change\": \"<string>\",\n              \"content\": \"<boolean>\"\n            },\n            {\n              \"change\": \"<string>\",\n              \"content\": \"<boolean>\"\n            }\n          ],\n          \"operator\": [\n            {\n              \"change\": \"<string>\",\n              \"content\": \"<boolean>\"\n            },\n            {\n              \"change\": \"<string>\",\n              \"content\": \"<boolean>\"\n            }\n          ],\n          \"value\": [\n            {\n              \"change\": \"<string>\",\n              \"content\": \"<boolean>\"\n            },\n            {\n              \"change\": \"<string>\",\n              \"content\": \"<boolean>\"\n            }\n          ]\n        },\n        \"description\": [\n          {\n            \"change\": \"<string>\",\n            \"content\": \"<boolean>\"\n          },\n          {\n            \"change\": \"<string>\",\n            \"content\": \"<boolean>\"\n          }\n        ],\n        \"source_id\": \"<integer>\",\n        \"target_id\": \"<integer>\",\n        \"title\": [\n          {\n            \"change\": \"<string>\",\n            \"content\": \"<boolean>\"\n          },\n          {\n            \"change\": \"<string>\",\n            \"content\": \"<boolean>\"\n          }\n        ]\n      },\n      \"id\": \"<integer>\",\n      \"snapshot\": {\n        \"actions\": [\n          {\n            \"field\": \"<string>\",\n            \"value\": \"<string>\"\n          },\n          {\n            \"field\": \"<string>\",\n            \"value\": \"<string>\"\n          }\n        ],\n        \"active\": \"<boolean>\",\n        \"conditions\": {\n          \"all\": [\n            {\n              \"field\": \"<string>\",\n              \"operator\": \"<string>\",\n              \"value\": \"<string>\"\n            },\n            {\n              \"field\": \"<string>\",\n              \"operator\": \"<string>\",\n              \"value\": \"<string>\"\n            }\n          ],\n          \"any\": [\n            {\n              \"field\": \"<string>\",\n              \"operator\": \"<string>\",\n              \"value\": \"<string>\"\n            },\n            {\n              \"field\": \"<string>\",\n              \"operator\": \"<string>\",\n              \"value\": \"<string>\"\n            }\n          ]\n        },\n        \"description\": \"<string>\",\n        \"title\": \"<string>\"\n      },\n      \"url\": \"<string>\"\n    },\n    {\n      \"author_id\": \"<integer>\",\n      \"created_at\": \"<string>\",\n      \"diff\": {\n        \"actions\": [\n          {\n            \"field\": [\n              {\n                \"change\": \"<string>\",\n                \"content\": \"<boolean>\"\n              },\n              {\n                \"change\": \"<string>\",\n                \"content\": \"<boolean>\"\n              }\n            ],\n            \"value\": [\n              {\n                \"change\": \"<string>\",\n                \"content\": \"<boolean>\"\n              },\n              {\n                \"change\": \"<string>\",\n                \"content\": \"<boolean>\"\n              }\n            ]\n          },\n          {\n            \"field\": [\n              {\n                \"change\": \"<string>\",\n                \"content\": \"<boolean>\"\n              },\n              {\n                \"change\": \"<string>\",\n                \"content\": \"<boolean>\"\n              }\n            ],\n            \"value\": [\n              {\n                \"change\": \"<string>\",\n                \"content\": \"<boolean>\"\n              },\n              {\n                \"change\": \"<string>\",\n                \"content\": \"<boolean>\"\n              }\n            ]\n          }\n        ],\n        \"active\": [\n          {\n            \"change\": \"<string>\",\n            \"content\": \"<boolean>\"\n          },\n          {\n            \"change\": \"<string>\",\n            \"content\": \"<boolean>\"\n          }\n        ],\n        \"conditions\": {\n          \"field\": [\n            {\n              \"change\": \"<string>\",\n              \"content\": \"<boolean>\"\n            },\n            {\n              \"change\": \"<string>\",\n              \"content\": \"<boolean>\"\n            }\n          ],\n          \"operator\": [\n            {\n              \"change\": \"<string>\",\n              \"content\": \"<boolean>\"\n            },\n            {\n              \"change\": \"<string>\",\n              \"content\": \"<boolean>\"\n            }\n          ],\n          \"value\": [\n            {\n              \"change\": \"<string>\",\n              \"content\": \"<boolean>\"\n            },\n            {\n              \"change\": \"<string>\",\n              \"content\": \"<boolean>\"\n            }\n          ]\n        },\n        \"description\": [\n          {\n            \"change\": \"<string>\",\n            \"content\": \"<boolean>\"\n          },\n          {\n            \"change\": \"<string>\",\n            \"content\": \"<boolean>\"\n          }\n        ],\n        \"source_id\": \"<integer>\",\n        \"target_id\": \"<integer>\",\n        \"title\": [\n          {\n            \"change\": \"<string>\",\n            \"content\": \"<boolean>\"\n          },\n          {\n            \"change\": \"<string>\",\n            \"content\": \"<boolean>\"\n          }\n        ]\n      },\n      \"id\": \"<integer>\",\n      \"snapshot\": {\n        \"actions\": [\n          {\n            \"field\": \"<string>\",\n            \"value\": \"<string>\"\n          },\n          {\n            \"field\": \"<string>\",\n            \"value\": \"<string>\"\n          }\n        ],\n        \"active\": \"<boolean>\",\n        \"conditions\": {\n          \"all\": [\n            {\n              \"field\": \"<string>\",\n              \"operator\": \"<string>\",\n              \"value\": \"<string>\"\n            },\n            {\n              \"field\": \"<string>\",\n              \"operator\": \"<string>\",\n              \"value\": \"<string>\"\n            }\n          ],\n          \"any\": [\n            {\n              \"field\": \"<string>\",\n              \"operator\": \"<string>\",\n              \"value\": \"<string>\"\n            },\n            {\n              \"field\": \"<string>\",\n              \"operator\": \"<string>\",\n              \"value\": \"<string>\"\n            }\n          ]\n        },\n        \"description\": \"<string>\",\n        \"title\": \"<string>\"\n      },\n      \"url\": \"<string>\"\n    }\n  ]\n}"
    }
  ]
}