{"id":19648334,"url":"https://github.com/bestpractical/rt-extension-rest2","last_synced_at":"2025-07-24T12:33:04.069Z","repository":{"id":14955669,"uuid":"17680383","full_name":"bestpractical/rt-extension-rest2","owner":"bestpractical","description":null,"archived":false,"fork":false,"pushed_at":"2022-07-13T20:34:32.000Z","size":809,"stargazers_count":27,"open_issues_count":5,"forks_count":11,"subscribers_count":26,"default_branch":"master","last_synced_at":"2025-04-28T15:44:25.442Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":"https://metacpan.org/pod/RT::Extension::REST2","language":"Perl","has_issues":false,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":null,"status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/bestpractical.png","metadata":{"files":{"readme":"README","changelog":"Changes","contributing":null,"funding":null,"license":null,"code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2014-03-12T19:21:33.000Z","updated_at":"2023-07-25T13:51:10.000Z","dependencies_parsed_at":"2022-07-16T03:16:14.522Z","dependency_job_id":null,"html_url":"https://github.com/bestpractical/rt-extension-rest2","commit_stats":null,"previous_names":[],"tags_count":15,"template":false,"template_full_name":null,"purl":"pkg:github/bestpractical/rt-extension-rest2","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/bestpractical%2Frt-extension-rest2","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/bestpractical%2Frt-extension-rest2/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/bestpractical%2Frt-extension-rest2/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/bestpractical%2Frt-extension-rest2/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/bestpractical","download_url":"https://codeload.github.com/bestpractical/rt-extension-rest2/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/bestpractical%2Frt-extension-rest2/sbom","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":266844052,"owners_count":23993962,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","status":"online","status_checked_at":"2025-07-24T02:00:09.469Z","response_time":99,"last_error":null,"robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":true,"can_crawl_api":true,"host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":[],"created_at":"2024-11-11T14:47:54.683Z","updated_at":"2025-07-24T12:33:04.016Z","avatar_url":"https://github.com/bestpractical.png","language":"Perl","funding_links":[],"categories":[],"sub_categories":[],"readme":"NAME\n    RT::Extension::REST2 - Adds a modern REST API to RT under /REST/2.0/\n\nRT VERSION\n    Works with RT 4.4.\n\n    REST2 is core in RT 5.0.0 and later, so you do not need this extension\n    for those versions.\n\nINSTALLATION\n    perl Makefile.PL\n    make\n    make install\n        May need root permissions\n\n    Edit your /opt/rt4/etc/RT_SiteConfig.pm\n        Add this line:\n\n            Plugin('RT::Extension::REST2');\n\n    Clear your mason cache\n            rm -rf /opt/rt4/var/mason_data/obj\n\n    Restart your webserver\n\nUSAGE\n  Tutorial\n    To make it easier to authenticate to REST2, we recommend installing\n    RT::Authen::Token. Visit \"Logged in as ___\" -\u003e Settings -\u003e Auth Tokens.\n    Create an Auth Token, give it any description (such as \"REST2 with\n    curl\"). Make note of the authentication token it provides to you.\n\n    For other authentication options see the section \"Authentication\n    Methods\" below.\n\n   Authentication\n    Run the following in a terminal, filling in XX_TOKEN_XX from the auth\n    token above and XX_RT_URL_XX with the URL for your RT instance.\n\n        curl -H 'Authorization: token XX_TOKEN_XX' 'XX_RT_URL_XX/REST/2.0/queues/all'\n\n    This does an authenticated request (using the Authorization HTTP header\n    with type token) for all of the queues you can see. You should see a\n    response, typical of search results, like this:\n\n        {\n           \"total\" : 1,\n           \"count\" : 1,\n           \"page\" : 1,\n           \"pages\" : 1,\n           \"per_page\" : 20,\n           \"items\" : [\n              {\n                 \"type\" : \"queue\",\n                 \"id\" : \"1\",\n                 \"_url\" : \"XX_RT_URL_XX/REST/2.0/queue/1\"\n              }\n           ]\n        }\n\n    This format is JSON, which is a format for which many programming\n    languages provide libraries for parsing and generating.\n\n    (If you instead see a response like {\"message\":\"Unauthorized\"} that\n    indicates RT couldn't process your authentication token successfully;\n    make sure the word \"token\" appears between \"Authorization:\" and the auth\n    token that RT provided to you)\n\n   Following Links\n    You can request one of the provided _urls to get more information about\n    that queue.\n\n        curl -H 'Authorization: token XX_TOKEN_XX' 'XX_QUEUE_URL_XX'\n\n    This will give a lot of information, like so:\n\n        {\n           \"id\" : 1,\n           \"Name\" : \"General\",\n           \"Description\" : \"The default queue\",\n           \"Lifecycle\" : \"default\",\n           ...\n           \"CustomFields\" : {},\n           \"_hyperlinks\" : [\n              {\n                 \"id\" : \"1\",\n                 \"ref\" : \"self\",\n                 \"type\" : \"queue\",\n                 \"_url\" : \"XX_RT_URL_XX/REST/2.0/queue/1\"\n              },\n              {\n                 \"ref\" : \"history\",\n                 \"_url\" : \"XX_RT_URL_XX/REST/2.0/queue/1/history\"\n              },\n              {\n                 \"ref\" : \"create\",\n                 \"type\" : \"ticket\",\n                 \"_url\" : \"XX_RT_URL_XX/REST/2.0/ticket?Queue=1\"\n              }\n           ],\n        }\n\n    Of particular note is the _hyperlinks key, which gives you a list of\n    related resources to examine (following the\n    \u003chttps://en.wikipedia.org/wiki/HATEOAS\u003e principle). For example an entry\n    with a ref of history lets you examine the transaction log for a record.\n    You can implement your REST API client knowing that any other hypermedia\n    link with a ref of history has the same meaning, regardless of whether\n    it's the history of a queue, ticket, asset, etc.\n\n    Another ref you'll see in _hyperlinks is create, with a type of ticket.\n    This of course gives you the URL to create tickets *in this queue*.\n    Importantly, if your user does *not* have the CreateTicket permission in\n    this queue, then REST2 would simply not include this hyperlink in its\n    response to your request. This allows you to dynamically adapt your\n    client's behavior to its presence or absence, just like the web version\n    of RT does.\n\n   Creating Tickets\n    Let's use the _url from the create hyperlink with type ticket.\n\n    To create a ticket is a bit more involved, since it requires providing a\n    different HTTP verb (POST instead of GET), a Content-Type header (to\n    tell REST2 that your content is JSON instead of, say, XML), and the\n    fields for your new ticket such as Subject. Here is the curl invocation,\n    wrapped to multiple lines for readability.\n\n        curl -X POST\n             -H \"Content-Type: application/json\"\n             -d '{ \"Subject\": \"hello world\" }'\n             -H 'Authorization: token XX_TOKEN_XX'\n                'XX_TICKET_CREATE_URL_XX'\n\n    If successful, that will provide output like so:\n\n        {\n            \"_url\" : \"XX_RT_URL_XX/REST/2.0/ticket/20\",\n            \"type\" : \"ticket\",\n            \"id\"   : \"20\"\n        }\n\n    (REST2 also produces the status code of 201 Created with a Location\n    header of the new ticket, which you may choose to use instead of the\n    JSON response)\n\n    We can fetch that _url to continue working with this newly-created\n    ticket. Request the ticket like so (make sure to include the -i flag to\n    see response's HTTP headers).\n\n        curl -i -H 'Authorization: token XX_TOKEN_XX' 'XX_TICKET_URL_XX'\n\n    You'll first see that there are many hyperlinks for tickets, including\n    one for each Lifecycle action you can perform, history, comment,\n    correspond, etc. Again these adapt to whether you have the appropriate\n    permissions to do these actions.\n\n    Additionally you'll see an ETag header for this record, which can be\n    used for conflict avoidance (\u003chttps://en.wikipedia.org/wiki/HTTP_ETag\u003e).\n    We'll first try updating this ticket with an *invalid* ETag to see what\n    happens.\n\n   Updating Tickets\n    For updating tickets we use the PUT verb, but otherwise it looks much\n    like a ticket creation.\n\n        curl -X PUT\n             -H \"Content-Type: application/json\"\n             -H \"If-Match: invalid-etag\"\n             -d '{ \"Subject\": \"trial update\" }'\n             -H 'Authorization: token XX_TOKEN_XX'\n                'XX_TICKET_URL_XX'\n\n    You'll get an error response like {\"message\":\"Precondition Failed\"} and\n    a status code of 412. If you examine the ticket, you'll also see that\n    its Subject was not changed. This is because the If-Match header advises\n    the server to make changes *if and only if* the ticket's ETag matches\n    what you provide. Since it differed, the server refused the request and\n    made no changes.\n\n    Now, try the same request by replacing the value \"invalid-etag\" in the\n    If-Match request header with the real ETag you'd received when you\n    requested the ticket previously. You'll then get a JSON response like:\n\n        [\"Ticket 1: Subject changed from 'hello world' to 'trial update'\"]\n\n    which is a list of messages meant for displaying to an end-user.\n\n    If you GET the ticket again, you'll observe that the ETag header now has\n    a different value, indicating that the ticket itself has changed. This\n    means if you were to retry the PUT update with the previous (at the\n    time, expected) ETag you would instead be rejected by the server with\n    Precondition Failed.\n\n    You can use ETag and If-Match headers to avoid race conditions such as\n    two people updating a ticket at the same time. Depending on the\n    sophistication of your client, you may be able to automatically retry\n    the change by incorporating the changes made on the server (for example\n    adding time worked can be automatically be recalculated).\n\n    You may of course choose to ignore the ETag header and not provide\n    If-Match in your requests; RT doesn't require its use.\n\n   Replying/Commenting Tickets\n    You can reply to or comment a ticket by POSTing to _url from the\n    correspond or comment hyperlinks that were returned when fetching the\n    ticket.\n\n        curl -X POST\n             -H \"Content-Type: application/json\"\n             -d '{\n                  \"Subject\"    : \"response\",\n                  \"Content\"    : \"What is your \u003cem\u003eissue\u003c/em\u003e?\",\n                  \"ContentType\": \"text/html\",\n                  \"TimeTaken\"  : \"1\"\n                }'\n             -H 'Authorization: token XX_TOKEN_XX'\n                'XX_TICKET_URL_XX'/correspond\n\n    Replying or commenting a ticket is quite similar to a ticket creation:\n    you send a POST request, with data encoded in JSON. The difference lies\n    in the properties of the JSON data object you can pass:\n\n    Subject\n        The subject of your response/comment, optional\n\n    Content\n        The content of your response/comment, mandatory unless there is a\n        non empty Attachments property to add at least one attachment to the\n        ticket (see \"Add Attachments\" section below).\n\n    ContentType\n        The MIME content type of your response/comment, typically text/plain\n        or /text/html, mandatory unless there is a non empty Attachments\n        property to add at least one attachment to the ticket (see \"Add\n        Attachments\" section below).\n\n    TimeTaken\n        The time, in minutes, you've taken to work on your response/comment,\n        optional.\n\n    Status\n        The new status (for example, \"open\", \"rejected\", etc.) to set the\n        ticket to. The Status value must be a valid status based on the\n        lifecycle of the ticket's current queue.\n\n    CustomRoles\n        A hash whose keys are custom role names and values are as described\n        below:\n\n        For a single-value custom role, the value must be a string\n        representing an email address or user name; the custom role is set\n        to the user with that email address or user name.\n\n        For a multi-value custom role, the value can be a string\n        representing an email address or user name, or can be an array of\n        email addresses or user names; in either case, the members of the\n        custom role are set to the corresponding users.\n\n    CustomFields\n        A hash similar to the CustomRoles hash, but whose keys are custom\n        field names that apply to the Ticket; those fields are set to the\n        supplied values.\n\n    TxnCustomFields\n        A hash similar to the CustomRoles hash, but whose keys are custom\n        field names that apply to the Transaction; those fields are set to\n        the supplied values.\n\n   Add Attachments\n    You can attach any binary or text file to your response or comment by\n    specifying Attachements property in the JSON object, which should be a\n    JSON array where each item represents a file you want to attach. Each\n    item is a JSON object with the following properties:\n\n    FileName\n        The name of the file to attach to your response/comment, mandatory.\n\n    FileType\n        The MIME type of the file to attach to your response/comment,\n        mandatory.\n\n    FileContent\n        The content, *encoded in MIME Base64* of the file to attach to your\n        response/comment, mandatory.\n\n    The reason why you should encode the content of any file to MIME Base64\n    is that a JSON string value should be a sequence of zero or more Unicode\n    characters. MIME Base64 is a binary-to-text encoding scheme widely used\n    (for eg. by web browser) to send binary data when text data is required.\n    Most popular language have MIME Base64 libraries that you can use to\n    encode the content of your attached files (see MIME::Base64 for Perl).\n    Note that even text files should be MIME Base64 encoded to be passed in\n    the FileContent property.\n\n    Here's a Perl example to send an image and a plain text file attached to\n    a comment:\n\n        #!/usr/bin/perl\n        use strict;\n        use warnings;\n\n        use LWP::UserAgent;\n        use JSON;\n        use MIME::Base64;\n        use Data::Dumper;\n\n        my $url = 'http://rt.local/REST/2.0/ticket/1/comment';\n\n        my $img_path = '/tmp/my_image.png';\n        my $img_content;\n        open my $img_fh, '\u003c', $img_path or die \"Cannot read $img_path: $!\\n\";\n        {\n            local $/;\n            $img_content = \u003c$img_fh\u003e;\n        }\n        close $img_fh;\n        $img_content = MIME::Base64::encode_base64($img_content);\n\n        my $txt_path = '~/.bashrc';\n        my $txt_content;\n        open my $txt_fh, '\u003c', glob($txt_path) or die \"Cannot read $txt_path: $!\\n\";\n        {\n            local $/;\n            $txt_content = \u003c$txt_fh\u003e;\n        }\n        close $txt_fh;\n        $txt_content = MIME::Base64::encode_base64($txt_content);\n\n        my $json = JSON-\u003enew-\u003eutf8;\n        my $payload = {\n            Content =\u003e '\u003cp\u003eI want \u003cb\u003etwo\u003c/b\u003e \u003cem\u003eattachments\u003c/em\u003e\u003c/p\u003e',\n            ContentType =\u003e 'text/html',\n            Subject =\u003e 'Attachments in JSON Array',\n            Attachments =\u003e [\n                {\n                    FileName =\u003e 'my_image.png',\n                    FileType =\u003e 'image/png',\n                    FileContent =\u003e $img_content,\n                },\n                {\n                    FileName =\u003e '.bashrc',\n                    FileType =\u003e 'text/plain',\n                    FileContent =\u003e $txt_content,\n                },\n            ],\n        };\n\n        my $req = HTTP::Request-\u003enew(POST =\u003e $url);\n        $req-\u003eheader('Authorization' =\u003e 'token 6-66-66666666666666666666666666666666');\n        $req-\u003eheader('Content-Type'  =\u003e 'application/json' );\n        $req-\u003eheader('Accept'        =\u003e 'application/json' );\n        $req-\u003econtent($json-\u003eencode($payload));\n\n        my $ua = LWP::UserAgent-\u003enew;\n        my $res = $ua-\u003erequest($req);\n        print Dumper($json-\u003edecode($res-\u003econtent)) . \"\\n\";\n\n    Encoding the content of attachments file in MIME Base64 has the drawback\n    of adding some processing overhead and to increase the sent data size by\n    around 33%. RT's REST2 API provides another way to attach any binary or\n    text file to your response or comment by POSTing, instead of a JSON\n    request, a multipart/form-data request. This kind of request is similar\n    to what the browser sends when you add attachments in RT's reply or\n    comment form. As its name suggests, a multipart/form-data request\n    message contains a series of parts, each representing a form field. To\n    reply to or comment a ticket, the request has to include a field named\n    JSON, which, as previously, is a JSON object with Subject, Content,\n    ContentType, TimeTaken properties. Files can then be attached by\n    specifying a field named Attachments for each of them, with the content\n    of the file as value and the appropriate MIME type.\n\n    The curl invocation is quite straightforward:\n\n        curl -X POST\n             -H \"Content-Type: multipart/form-data\"\n             -F 'JSON={\n                        \"Subject\"    : \"Attachments in multipart/form-data\",\n                        \"Content\"    : \"\u003cp\u003eI want \u003cb\u003etwo\u003c/b\u003e \u003cem\u003eattachments\u003c/em\u003e\u003c/p\u003e\",\n                        \"ContentType\": \"text/html\",\n                        \"TimeTaken\"  : \"1\"\n                      };type=application/json'\n             -F 'Attachments=@/tmp/my_image.png;type=image/png'\n             -F 'Attachments=@/tmp/.bashrc;type=text/plain'\n             -H 'Authorization: token XX_TOKEN_XX'\n                'XX_TICKET_URL_XX'/comment\n\n   Summary\n    RT's REST2 API provides the tools you need to build robust and dynamic\n    integrations. Tools like ETag/If-Match allow you to avoid conflicts such\n    as two people taking a ticket at the same time. Using JSON for all data\n    interchange avoids problems caused by parsing text. Hypermedia links\n    inform your client application of what the user has the ability to do.\n\n    Careful readers will see that, other than our initial entry into the\n    system, we did not *generate* any URLs. We only *followed* links, just\n    like you do when browsing a website on your computer. We've better\n    decoupled the client's implementation from the server's REST API.\n    Additionally, this system lets you be informed of new capabilities in\n    the form of additional hyperlinks.\n\n    Using these tools and principles, REST2 will help you build rich,\n    robust, and powerful integrations with the other applications and\n    services that your team uses.\n\n  Endpoints\n    Currently provided endpoints under /REST/2.0/ are described below.\n    Wherever possible please consider using _hyperlinks hypermedia controls\n    available in response bodies rather than hardcoding URLs.\n\n    For simplicity, the examples below omit the extra options to curl for\n    SSL like --cacert.\n\n   Tickets\n        GET /tickets?query=\u003cTicketSQL\u003e\n            search for tickets using TicketSQL\n\n        GET /tickets?simple=1;query=\u003csimple search query\u003e\n            search for tickets using simple search syntax\n\n        # If there are multiple saved searches using the same description, the\n        # behavior of \"which saved search shall be selected\" is undefined, use\n        # id instead in this case.\n\n        # If both search and other arguments like \"query\" are specified, the\n        # latter takes higher precedence than the corresponding fields defined\n        # in the given saved search.\n\n        GET /tickets?search=\u003csaved search id or description\u003e\n            search for tickets using saved search\n\n        POST /tickets\n            search for tickets with the 'search' or 'query' and optional 'simple' parameters \n\n        POST /ticket\n            create a ticket; provide JSON content\n\n        GET /ticket/:id\n            retrieve a ticket\n\n        PUT /ticket/:id\n            update a ticket's metadata; provide JSON content\n\n        DELETE /ticket/:id\n            set status to deleted\n\n        POST /ticket/:id/correspond\n        POST /ticket/:id/comment\n            add a reply or comment to the ticket\n\n        GET /ticket/:id/history\n            retrieve list of transactions for ticket\n\n        POST /tickets/bulk\n            create multiple tickets; provide JSON content(array of hashes)\n\n        PUT /tickets/bulk\n            update multiple tickets' metadata; provide JSON content(array of hashes)\n\n        POST /tickets/bulk/correspond\n        POST /tickets/bulk/comment\n            add a reply or comment to multiple tickets; provide JSON content(array of hashes)\n\n   Ticket Examples\n    Below are some examples using the endpoints above.\n\n        # Create a ticket, setting some custom fields and a custom role\n        curl -X POST -H \"Content-Type: application/json\" -u 'root:password'\n            -d '{ \"Queue\": \"General\", \"Subject\": \"Create ticket test\",\n                \"Requestor\": \"user1@example.com\", \"Cc\": \"user2@example.com\",\n                \"CustomRoles\": {\"My Role\": \"staff1@example.com\"},\n                \"Content\": \"Testing a create\",\n                \"CustomFields\": {\"Severity\": \"Low\"}}'\n            'https://myrt.com/REST/2.0/ticket'\n\n        # Update a ticket, with a custom field update\n        curl -X PUT -H \"Content-Type: application/json\" -u 'root:password'\n            -d '{ \"Subject\": \"Update test\", \"CustomFields\": {\"Severity\": \"High\"}}'\n            'https://myrt.com/REST/2.0/ticket/6'\n\n        # Correspond a ticket\n        curl -X POST -H \"Content-Type: application/json\" -u 'root:password'\n            -d '{ \"Content\": \"Testing a correspondence\", \"ContentType\": \"text/plain\" }'\n            'https://myrt.com/REST/2.0/ticket/6/correspond'\n\n        # Correspond a ticket with a transaction custom field\n        curl -X POST -H \"Content-Type: application/json\" -u 'root:password'\n            -d '{ \"Content\": \"Testing a correspondence\", \"ContentType\": \"text/plain\",\n                  \"TxnCustomFields\": {\"MyField\": \"custom field value\"} }'\n            'https://myrt.com/REST/2.0/ticket/6/correspond'\n\n        # Comment on a ticket\n        curl -X POST -H \"Content-Type: text/plain\" -u 'root:password'\n            -d 'Testing a comment'\n            'https://myrt.com/REST/2.0/ticket/6/comment'\n\n        # Comment on a ticket with custom field update\n        curl -X POST -H \"Content-Type: application/json\" -u 'root:password'\n            -d '{ \"Content\": \"Testing a comment\", \"ContentType\": \"text/plain\", \"CustomFields\": {\"Severity\": \"High\"} }'\n            'https://myrt.com/REST/2.0/ticket/6/comment'\n\n        # Comment on a ticket with custom role update\n        curl -X POST -H \"Content-Type: application/json\" -u 'root:password'\n            -d '{ \"Content\": \"Testing a comment\", \"ContentType\": \"text/plain\", \"CustomRoles\": {\"Manager\": \"manager@example.com\"} }'\n            'https://myrt.com/REST/2.0/ticket/6/comment'\n\n        # Update many tickets at once with bulk by sending an array with ticket ids\n        # Results are returned for each update in a JSON array with ticket ids and corresponding messages\n        curl -X POST -H \"Content-Type: application/json\" -u 'root:password'\n            -d '[{ \"id\": \"20\", \"Content\": \"Testing a correspondence\", \"ContentType\": \"text/plain\" },\n                 { \"id\": \"18\", \"Content\": \"Testing a correspondence\", \"ContentType\": \"text/plain\", \"Status\":\"resolved\", \"CustomRoles\": {\"Manager\": \"manager@example.com\"}, \"CustomFields\": {\"State\": \"New York\"} }]'\n            'https://myrt.com/REST/2.0/tickets/bulk/correspond'\n\n        [[\"20\",\"Correspondence added\"],[\"18\",\"Correspondence added\",\"State New York added\",\"Added manager@example.com as Manager for this ticket\",\"Status changed from 'open' to 'resolved'\"]]\n\n   Transactions\n        GET /transactions?query=\u003cJSON\u003e\n        POST /transactions\n            search for transactions using L\u003c/JSON searches\u003e syntax\n\n        GET /ticket/:id/history\n        GET /queue/:id/history\n        GET /queue/:name/history\n        GET /asset/:id/history\n        GET /user/:id/history\n        GET /user/:name/history\n        GET /group/:id/history\n            get transactions for record\n\n        GET /transaction/:id\n            retrieve a transaction\n\n   Attachments and Messages\n        GET /attachments?query=\u003cJSON\u003e\n        POST /attachments\n            search for attachments using L\u003c/JSON searches\u003e syntax\n\n        GET /transaction/:id/attachments\n            get attachments for transaction\n\n        GET /attachment/:id\n            retrieve an attachment\n\n   Image and Binary Object Custom Field Values\n        GET /download/cf/:id\n            retrieve an image or a binary file as an object custom field value\n\n   Queues\n        GET /queues/all\n            retrieve list of all queues you can see\n\n        GET /queues?query=\u003cJSON\u003e\n        POST /queues\n            search for queues using L\u003c/JSON searches\u003e syntax\n\n        POST /queue\n            create a queue; provide JSON content\n\n        GET /queue/:id\n        GET /queue/:name\n            retrieve a queue by numeric id or name\n\n        PUT /queue/:id\n        PUT /queue/:name\n            update a queue's metadata; provide JSON content\n\n        DELETE /queue/:id\n        DELETE /queue/:name\n            disable queue\n\n        GET /queue/:id/history\n        GET /queue/:name/history\n            retrieve list of transactions for queue\n\n   Assets\n        GET /assets?query=\u003cJSON\u003e\n        POST /assets\n            search for assets using L\u003c/JSON searches\u003e syntax\n\n        POST /asset\n            create an asset; provide JSON content\n\n        GET /asset/:id\n            retrieve an asset\n\n        PUT /asset/:id\n            update an asset's metadata; provide JSON content\n\n        DELETE /asset/:id\n            set status to deleted\n\n        GET /asset/:id/history\n            retrieve list of transactions for asset\n\n   Assets Examples\n    Below are some examples using the endpoints above.\n\n        # Create an Asset\n        curl -X POST -H \"Content-Type: application/json\" -u 'root:password'\n            -d '{\"Name\" : \"Asset From Rest\", \"Catalog\" : \"General assets\", \"Content\" : \"Some content\"}'\n            'https://myrt.com/REST/2.0/asset'\n\n        # Search Assets\n        curl -X POST -H \"Content-Type: application/json\" -u 'root:password'\n        -d '[{ \"field\" : \"id\", \"operator\" : \"\u003e=\", \"value\" : 0 }]'\n        'https://myrt.com/REST/2.0/assets'\n\n   Catalogs\n        GET /catalogs/all\n            retrieve list of all catalogs you can see\n\n        GET /catalogs?query=\u003cJSON\u003e\n        POST /catalogs\n            search for catalogs using L\u003c/JSON searches\u003e syntax\n\n        POST /catalog\n            create a catalog; provide JSON content\n\n        GET /catalog/:id\n        GET /catalog/:name\n            retrieve a catalog by numeric id or name\n\n        PUT /catalog/:id\n        PUT /catalog/:name\n            update a catalog's metadata; provide JSON content\n\n        DELETE /catalog/:id\n        DELETE /catalog/:name\n            disable catalog\n\n   Users\n        GET /users?query=\u003cJSON\u003e\n        POST /users\n            search for users using L\u003c/JSON searches\u003e syntax\n\n        POST /user\n            create a user; provide JSON content\n\n        GET /user/:id\n        GET /user/:name\n            retrieve a user by numeric id or username (including its memberships and whether it is disabled)\n\n        PUT /user/:id\n        PUT /user/:name\n            update a user's metadata (including its Disabled status); provide JSON content\n\n        DELETE /user/:id\n        DELETE /user/:name\n            disable user\n\n        GET /user/:id/history\n        GET /user/:name/history\n            retrieve list of transactions for user\n\n   Groups\n        GET /groups?query=\u003cJSON\u003e\n        POST /groups\n            search for groups using L\u003c/JSON searches\u003e syntax\n\n        POST /group\n            create a (user defined) group; provide JSON content\n\n        GET /group/:id\n            retrieve a group (including its members and whether it is disabled)\n\n        PUT /group/:id\n            update a groups's metadata (including its Disabled status); provide JSON content\n\n        DELETE /group/:id\n            disable group\n\n        GET /group/:id/history\n            retrieve list of transactions for group\n\n   User Memberships\n        GET /user/:id/groups\n        GET /user/:name/groups\n            retrieve list of groups which a user is a member of\n\n        PUT /user/:id/groups\n        PUT /user/:name/groups\n            add a user to groups; provide a JSON array of groups ids\n\n        DELETE /user/:id/group/:id\n        DELETE /user/:name/group/:id\n            remove a user from a group\n\n        DELETE /user/:id/groups\n        DELETE /user/:name/groups\n            remove a user from all groups\n\n   Group Members\n        GET /group/:id/members\n            retrieve list of direct members of a group\n\n        GET /group/:id/members?recursively=1\n            retrieve list of direct and recursive members of a group\n\n        GET /group/:id/members?users=0\n            retrieve list of direct group members of a group\n\n        GET /group/:id/members?users=0\u0026recursively=1\n            retrieve list of direct and recursive group members of a group\n\n        GET /group/:id/members?groups=0\n            retrieve list of direct user members of a group\n\n        GET /group/:id/members?groups=0\u0026recursively=1\n            retrieve list of direct and recursive user members of a group\n\n        PUT /group/:id/members\n            add members to a group; provide a JSON array of principal ids\n\n        DELETE /group/:id/member/:id\n            remove a member from a group\n\n        DELETE /group/:id/members\n            remove all members from a group\n\n   Custom Fields\n        GET /customfields?query=\u003cJSON\u003e\n        POST /customfields\n            search for custom fields using L\u003c/JSON searches\u003e syntax\n\n        POST /customfield\n            create a customfield; provide JSON content\n\n        GET /catalog/:id/customfields?query=\u003cJSON\u003e\n        POST /catalog/:id/customfields\n            search for custom fields attached to a catalog using L\u003c/JSON searches\u003e syntax\n\n        GET /class/:id/customfields?query=\u003cJSON\u003e\n        POST /class/:id/customfields\n            search for custom fields attached to a class using L\u003c/JSON searches\u003e syntax\n\n        GET /queue/:id/customfields?query=\u003cJSON\u003e\n        POST /queue/:id/customfields\n            search for custom fields attached to a queue using L\u003c/JSON searches\u003e syntax\n\n        GET /customfield/:id\n            retrieve a custom field, with values if type is Select\n\n        GET /customfield/:id?category=\u003ccategory name\u003e\n            retrieve a custom field, with values filtered by category if type is Select\n\n        PUT /customfield/:id\n            update a custom field's metadata; provide JSON content\n\n        DELETE /customfield/:id\n            disable customfield\n\n   Custom Field Values\n        GET /customfield/:id/values?query=\u003cJSON\u003e\n        POST /customfield/:id/values\n            search for values of a custom field  using L\u003c/JSON searches\u003e syntax\n\n        POST /customfield/:id/value\n            add a value to a custom field; provide JSON content\n\n        GET /customfield/:id/value/:id\n            retrieve a value of a custom field\n\n        PUT /customfield/:id/value/:id\n            update a value of a custom field; provide JSON content\n\n        DELETE /customfield/:id/value/:id\n            remove a value from a custom field\n\n   Custom Roles\n        GET /customroles?query=\u003cJSON\u003e\n        POST /customroles\n            search for custom roles using L\u003c/JSON searches\u003e syntax\n\n        GET /customrole/:id\n            retrieve a custom role\n\n   Saved Searches\n        GET /searches?query=\u003cJSON\u003e\n        POST /searches\n            search for saved searches using L\u003c/JSON searches\u003e syntax\n\n        GET /search/:id\n        GET /search/:description\n            retrieve a saved search\n\n   Miscellaneous\n        GET /\n            produces this documentation\n\n        GET /rt\n            produces system information\n\n  JSON searches\n    Some resources accept a basic JSON structure as the search conditions\n    which specifies one or more fields to limit on (using specified\n    operators and values). An example:\n\n        curl -si -u user:pass https://rt.example.com/REST/2.0/queues -XPOST --data-binary '\n            [\n                { \"field\":    \"Name\",\n                  \"operator\": \"LIKE\",\n                  \"value\":    \"Engineering\" },\n\n                { \"field\":    \"Lifecycle\",\n                  \"value\":    \"helpdesk\" }\n            ]\n        '\n\n    The JSON payload must be an array of hashes with the keys field and\n    value and optionally operator.\n\n    Results can be sorted by using multiple query parameter arguments\n    orderby and order. Each orderby query parameter specify a field to be\n    used for sorting results. If the request includes more than one orderby\n    query parameter, results are sorted according to corresponding fields in\n    the same order than they are specified. For instance, if you want to\n    sort results according to creation date and then by id (in case of some\n    items have the same creation date), your request should specify\n    ?orderby=Created\u0026orderby=id. By default, results are sorted in ascending\n    order. To sort results in descending order, you should use order=DESC\n    query parameter. Any other value for order query parameter will be\n    treated as order=ASC, for ascending order. The order of the order query\n    parameters should be the same as the orderby query parameters.\n    Therefore, if you specify two fields to sort the results (with two\n    orderby parameters) and you want to sort the second field by descending\n    order, you should also explicitely specify order=ASC for the first\n    field: orderby=Created\u0026order=ASC\u0026orderby=id\u0026order=DESC. orderby and\n    order query parameters are supported in both JSON and TicketSQL\n    searches.\n\n    The same field is specified more than one time to express more than one\n    condition on this field. For example:\n\n        [\n            { \"field\":    \"id\",\n              \"operator\": \"\u003e\",\n              \"value\":    $min },\n\n            { \"field\":     \"id\",\n              \"operator\": \"\u003c\",\n              \"value\":    $max }\n        ]\n\n    By default, RT will aggregate these conditions with an OR, except for\n    when searching queues, where an AND is applied. If you want to search\n    for multiple conditions on the same field aggregated with an AND (or an\n    OR for queues), you can specify entry_aggregator keys in corresponding\n    hashes:\n\n        [\n            { \"field\":    \"id\",\n              \"operator\": \"\u003e\",\n              \"value\":    $min },\n\n            { \"field\":             \"id\",\n              \"operator\":         \"\u003c\",\n              \"value\":            $max,\n              \"entry_aggregator\": \"AND\" }\n        ]\n\n    Results are returned in the format described below.\n\n  Example of plural resources (collections)\n    Resources which represent a collection of other resources use the\n    following standard JSON format:\n\n        {\n           \"count\" : 20,\n           \"page\" : 1,\n           \"pages\" : 191,\n           \"per_page\" : 20,\n           \"next_page\" : \"\u003ccollection path\u003e?page=2\"\n           \"total\" : 3810,\n           \"items\" : [\n              { … },\n              { … },\n              …\n           ]\n        }\n\n    Each item is nearly the same representation used when an individual\n    resource is requested.\n\n  Object Custom Field Values\n    When creating (via POST) or updating (via PUT) a resource which has some\n    custom fields attached to, you can specify the value(s) for these\n    customfields in the CustomFields property of the JSON object parameter.\n    The CustomFields property should be a JSON object, with each property\n    being the custom field identifier or name. If the custom field can have\n    only one value, you just have to speciy the value as JSON string for\n    this custom field. If the customfield can have several value, you have\n    to specify a JSON array of each value you want for this custom field.\n\n        \"CustomFields\": {\n            \"XX_SINGLE_CF_ID_XX\"   : \"My Single Value\",\n            \"XX_MULTI_VALUE_CF_ID\": [\n                \"My First Value\",\n                \"My Second Value\"\n            ]\n        }\n\n    Note that for a multi-value custom field, you have to specify all the\n    values for this custom field. Therefore if the customfield for this\n    resource already has some values, the existing values must be including\n    in your update request if you want to keep them (and add some new\n    values). Conversely, if you want to delete some existing values, do not\n    include them in your update request (including only values you wan to\n    keep). The following example deletes \"My Second Value\" from the previous\n    example:\n\n        \"CustomFields\": {\n            \"XX_MULTI_VALUE_CF_ID\": [\n                \"My First Value\"\n            ]\n        }\n\n    To delete a single-value custom field, set its value to JSON null (undef\n    in Perl):\n\n        \"CustomFields\": {\n            \"XX_SINGLE_CF_ID_XX\" : null\n        }\n\n    New values for Image and Binary custom fields can be set by specifying a\n    JSON object as value for the custom field identifier or name with the\n    following properties:\n\n    FileName\n        The name of the file to attach, mandatory.\n\n    FileType\n        The MIME type of the file to attach, mandatory.\n\n    FileContent\n        The content, *encoded in MIME Base64* of the file to attach,\n        mandatory.\n\n    The reason why you should encode the content of the image or binary file\n    to MIME Base64 is that a JSON string value should be a sequence of zero\n    or more Unicode characters. MIME Base64 is a binary-to-text encoding\n    scheme widely used (for eg. by web browser) to send binary data when\n    text data is required. Most popular language have MIME Base64 libraries\n    that you can use to encode the content of your attached files (see\n    MIME::Base64 for Perl). Note that even text files should be MIME Base64\n    encoded to be passed in the FileContent property.\n\n        \"CustomFields\": {\n            \"XX_SINGLE_IMAGE_OR_BINARY_CF_ID_XX\"   : {\n                \"FileName\"   : \"image.png\",\n                \"FileType\"   : \"image/png\",\n                \"FileContent\": \"XX_BASE_64_STRING_XX\"\n            },\n            \"XX_MULTI_VALUE_IMAGE_OR_BINARY_CF_ID\": [\n                {\n                    \"FileName\"   : \"another_image.png\",\n                    \"FileType\"   : \"image/png\",\n                    \"FileContent\": \"XX_BASE_64_STRING_XX\"\n                },\n                {\n                    \"FileName\"   : \"hello_world.txt\",\n                    \"FileType\"   : \"text/plain\",\n                    \"FileContent\": \"SGVsbG8gV29ybGQh\"\n                }\n            ]\n        }\n\n    Encoding the content of image or binary files in MIME Base64 has the\n    drawback of adding some processing overhead and to increase the sent\n    data size by around 33%. RT's REST2 API provides another way to upload\n    image or binary files as custom field alues by sending, instead of a\n    JSON request, a multipart/form-data request. This kind of request is\n    similar to what the browser sends when you upload a file in RT's ticket\n    creation or update forms. As its name suggests, a multipart/form-data\n    request message contains a series of parts, each representing a form\n    field. To create or update a ticket with image or binary file, the\n    multipart/form-data request has to include a field named JSON, which, as\n    previously, is a JSON object with Queue, Subject, Content, ContentType,\n    etc. properties. But instead of specifying each custom field value as a\n    JSON object with FileName, FileType and FileContent properties, each\n    custom field value should be a JSON object with UploadField. You can\n    choose anything you want for this field name, except *Attachments*,\n    which should be reserved for attaching files to a response or a comment\n    to a ticket. Files can then be attached by specifying a field named as\n    specified in the CustomFields property for each of them, with the\n    content of the file as value and the appropriate MIME type.\n\n    Here is an exemple of a curl invocation, wrapped to multiple lines for\n    readability, to create a ticket with a multipart/request to upload some\n    image or binary files as custom fields values.\n\n        curl -X POST\n             -H \"Content-Type: multipart/form-data\"\n             -F 'JSON={\n                        \"Queue\"      : \"General\",\n                        \"Subject\"    : \"hello world\",\n                        \"Content\"    : \"That \u003cem\u003edamned\u003c/em\u003e printer is out of order \u003cb\u003eagain\u003c/b\u003e!\",\n                        \"ContentType\": \"text/html\",\n                        \"CustomFields\"  : {\n                            \"XX_SINGLE_IMAGE_OR_BINARY_CF_ID_XX\"   =\u003e { \"UploadField\": \"FILE_1\",\n                            \"XX_MULTI_VALUE_IMAGE_OR_BINARY_CF_ID\" =\u003e [ { \"UploadField\": \"FILE_2\" }, { \"UploadField\": \"FILE_3\" } ]\n                        }\n                      };type=application/json'\n             -F 'FILE_1=@/tmp/image.png;type=image/png'\n             -F 'FILE_2=@/tmp/another_image.png;type=image/png'\n             -F 'FILE_3=@/etc/cups/cupsd.conf;type=text/plain'\n             -H 'Authorization: token XX_TOKEN_XX'\n                'XX_RT_URL_XX'/tickets\n\n    If you want to delete some existing values from a multi-value image or\n    binary custom field, you can just pass the existing filename as value\n    for the custom field identifier or name, no need to upload again the\n    content of the file. The following example will delete the text file and\n    keep the image upload in previous example:\n\n        \"CustomFields\": {\n            \"XX_MULTI_VALUE_IMAGE_OR_BINARY_CF_ID\": [\n                    \"image.png\"\n            ]\n        }\n\n    To download an image or binary file which is the custom field value of a\n    resource, you just have to make a GET request to the entry point\n    returned for the corresponding custom field when fetching this resource,\n    and it will return the content of the file as an octet string:\n\n        curl -i -H 'Authorization: token XX_TOKEN_XX' 'XX_TICKET_URL_XX'\n\n        {\n            […]\n            \"XX_IMAGE_OR_BINARY_CF_ID_XX\" : [\n                {\n                    \"content_type\" : \"image/png\",\n                    \"filename\" : \"image.png\",\n                    \"_url\" : \"XX_RT_URL_XX/REST/2.0/download/cf/XX_IMAGE_OR_BINARY_OCFV_ID_XX\"\n                }\n            ],\n            […]\n        },\n\n        curl -i -H 'Authorization: token XX_TOKEN_XX'\n            'XX_RT_URL_XX/REST/2.0/download/cf/XX_IMAGE_OR_BINARY_OCFV_ID_XX'\n            \u003e file.png\n\n  Paging\n    All plural resources (such as /tickets) require pagination, controlled\n    by the query parameters page and per_page. The default page size is 20\n    items, but it may be increased up to 100 (or decreased if desired). Page\n    numbers start at 1. The number of pages is returned, and if there is a\n    next or previous page, then the URL for that page is returned in the\n    next_page and prev_page variables respectively. It is up to you to store\n    the required JSON to pass with the following page request.\n\n  Disabled items\n    By default, only enabled objects are returned. To include disabled\n    objects you can specify find_disabled_rows=1 as a query parameter.\n\n  Fields\n    When fetching search results you can include additional fields by adding\n    a query parameter fields which is a comma seperated list of fields to\n    include. You must use the camel case version of the name as included in\n    the results for the actual item.\n\n    You can use additional fields parameters to expand child blocks, for\n    example (line wrapping inserted for readability):\n\n        XX_RT_URL_XX/REST/2.0/tickets\n          ?fields=Owner,Status,Created,Subject,Queue,CustomFields,Requestor,Cc,AdminCc,RT::CustomRole-1\n          \u0026fields[Queue]=Name,Description\n\n    Says that in the result set for tickets, the extra fields for Owner,\n    Status, Created, Subject, Queue, CustomFields, Requestor, Cc, AdminCc\n    and CustomRoles should be included. But in addition, for the Queue\n    block, also include Name and Description. The results would be similar\n    to this (only one ticket is displayed in this example):\n\n       \"items\" : [\n          {\n             \"Subject\" : \"Sample Ticket\",\n             \"id\" : \"2\",\n             \"type\" : \"ticket\",\n             \"Owner\" : {\n                \"id\" : \"root\",\n                \"_url\" : \"XX_RT_URL_XX/REST/2.0/user/root\",\n                \"type\" : \"user\"\n             },\n             \"_url\" : \"XX_RT_URL_XX/REST/2.0/ticket/2\",\n             \"Status\" : \"resolved\",\n             \"Created\" : \"2018-06-29:10:25Z\",\n             \"Queue\" : {\n                \"id\" : \"1\",\n                \"type\" : \"queue\",\n                \"Name\" : \"General\",\n                \"Description\" : \"The default queue\",\n                \"_url\" : \"XX_RT_URL_XX/REST/2.0/queue/1\"\n             },\n             \"CustomFields\" : [\n                 {\n                     \"id\" : \"1\",\n                     \"type\" : \"customfield\",\n                     \"_url\" : \"XX_RT_URL_XX/REST/2.0/customfield/1\",\n                     \"name\" : \"My Custom Field\",\n                     \"values\" : [\n                         \"CustomField value\"\n                     ]\n                 }\n             ],\n             \"Requestor\" : [\n                {\n                   \"id\" : \"root\",\n                   \"type\" : \"user\",\n                   \"_url\" : \"XX_RT_URL_XX/REST/2.0/user/root\"\n                }\n             ],\n             \"Cc\" : [\n                {\n                   \"id\" : \"root\",\n                   \"type\" : \"user\",\n                   \"_url\" : \"XX_RT_URL_XX/REST/2.0/user/root\"\n                }\n             ],\n             \"AdminCc\" : [],\n             \"RT::CustomRole-1\" : [\n                {\n                   \"_url\" : \"XX_RT_URL_XX/REST/2.0/user/foo@example.com\",\n                   \"type\" : \"user\",\n                   \"id\" : \"foo@example.com\"\n                }\n             ]\n          }\n          { … },\n          …\n       ],\n\n    If the user performing the query doesn't have rights to view the record\n    (or sub record), then the empty string will be returned.\n\n    For single object URLs like /ticket/:id, as it already contains all the\n    fields by default, parameter \"fields\" is not needed, but you can still\n    use additional fields parameters to expand child blocks:\n\n        XX_RT_URL_XX/REST/2.0/ticket/1?fields[Queue]=Name,Description\n\n  Authentication Methods\n    Authentication should always be done over HTTPS/SSL for security. You\n    should only serve up the /REST/2.0/ endpoint over SSL.\n\n   Basic Auth\n    Authentication may use internal RT usernames and passwords, provided via\n    HTTP Basic auth. Most HTTP libraries already have a way of providing\n    basic auth credentials when making requests. Using curl, for example:\n\n        curl -u 'username:password' /path/to/REST/2.0\n\n   Token Auth\n    You may use the RT::Authen::Token extension to authenticate to the REST\n    2 API. Once you've acquired an authentication token in the web\n    interface, specify the Authorization header with a value of \"token\" like\n    so:\n\n        curl -H 'Authorization: token …' /path/to/REST/2.0\n\n    If the library or application you're using does not support specifying\n    additional HTTP headers, you may also pass the authentication token as a\n    query parameter like so:\n\n        curl /path/to/REST/2.0?token=…\n\n   Cookie Auth\n    Finally, you may reuse an existing cookie from an ordinary web session\n    to authenticate against REST2. This is primarily intended for\n    interacting with REST2 via JavaScript in the browser. Other REST\n    consumers are advised to use the alternatives above.\n\n  Conditional requests (If-Modified-Since, If-Match)\n    You can take advantage of the Last-Modified headers returned by most\n    single resource endpoints. Add a If-Modified-Since header to your\n    requests for the same resource, using the most recent Last-Modified\n    value seen, and the API may respond with a 304 Not Modified. You can\n    also use HEAD requests to check for updates without receiving the actual\n    content when there is a newer version. You may also add an\n    If-Unmodified-Since header to your updates to tell the server to refuse\n    updates if the record had been changed since you last retrieved it.\n\n    ETag, If-Match, and If-None-Match work similarly to Last-Modified,\n    If-Modified-Since, and If-Unmodified-Since, except that they don't use a\n    timestamp, which has its own set of tradeoffs. ETag is an opaque value,\n    so it has no meaning to consumers (unlike timestamps). However,\n    timestamps have the disadvantage of having a resolution of seconds, so\n    two updates happening in the same second would produce incorrect\n    results, whereas ETag does not suffer from that problem.\n\n  Status codes\n    The REST API uses the full range of HTTP status codes, and your client\n    should handle them appropriately.\n\nAUTHOR\n    Best Practical Solutions, LLC \u003cmodules@bestpractical.com\u003e\n\nBUGS\n    All bugs should be reported via email to\n    bug-RT-Extension-REST2@rt.cpan.org\n    \u003cmailto:bug-RT-Extension-REST2@rt.cpan.org\u003e or via the web at\n    rt.cpan.org\n    \u003chttp://rt.cpan.org/Public/Dist/Display.html?Name=RT-Extension-REST2\u003e.\n\nLICENSE AND COPYRIGHT\n    This software is Copyright (c) 2015-2020 by Best Practical Solutions,\n    LLC.\n\n    This is free software, licensed under:\n\n    The GNU General Public License, Version 2, June 1991\n\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fbestpractical%2Frt-extension-rest2","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fbestpractical%2Frt-extension-rest2","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fbestpractical%2Frt-extension-rest2/lists"}