SQL Server / Support API / List All Ticket Audits
Back to Collection Items
-- Important: See this note about string length limitations for strings returned by sp_OAMethod calls.
--
CREATE PROCEDURE ChilkatSample
AS
BEGIN
DECLARE @hr int
DECLARE @iTmp0 int
-- Important: Do not use nvarchar(max). See the warning about using nvarchar(max).
DECLARE @sTmp0 nvarchar(4000)
-- This example assumes the Chilkat API to have been previously unlocked.
-- See Global Unlock Sample for sample code.
DECLARE @http int
-- Use "Chilkat_9_5_0.Http" for versions of Chilkat < 10.0.0
EXEC @hr = sp_OACreate 'Chilkat.Http', @http OUT
IF @hr <> 0
BEGIN
PRINT 'Failed to create ActiveX component'
RETURN
END
DECLARE @success int
EXEC sp_OASetProperty @http, 'BasicAuth', 1
EXEC sp_OASetProperty @http, 'Login', 'login'
EXEC sp_OASetProperty @http, 'Password', 'password'
DECLARE @queryParams int
-- Use "Chilkat_9_5_0.JsonObject" for versions of Chilkat < 10.0.0
EXEC @hr = sp_OACreate 'Chilkat.JsonObject', @queryParams OUT
EXEC sp_OAMethod @queryParams, 'UpdateString', @success OUT, 'limit', '<integer>'
EXEC sp_OAMethod @http, 'SetRequestHeader', NULL, 'Accept', 'application/json'
DECLARE @resp int
EXEC sp_OAMethod @http, 'QuickRequestParams', @resp OUT, 'GET', 'https://example.zendesk.com/api/v2/ticket_audits', @queryParams
EXEC sp_OAGetProperty @http, 'LastMethodSuccess', @iTmp0 OUT
IF @iTmp0 = 0
BEGIN
EXEC sp_OAGetProperty @http, 'LastErrorText', @sTmp0 OUT
PRINT @sTmp0
EXEC @hr = sp_OADestroy @http
EXEC @hr = sp_OADestroy @queryParams
RETURN
END
DECLARE @sbResponseBody int
-- Use "Chilkat_9_5_0.StringBuilder" for versions of Chilkat < 10.0.0
EXEC @hr = sp_OACreate 'Chilkat.StringBuilder', @sbResponseBody OUT
EXEC sp_OAMethod @resp, 'GetBodySb', @success OUT, @sbResponseBody
DECLARE @jResp int
-- Use "Chilkat_9_5_0.JsonObject" for versions of Chilkat < 10.0.0
EXEC @hr = sp_OACreate 'Chilkat.JsonObject', @jResp OUT
EXEC sp_OAMethod @jResp, 'LoadSb', @success OUT, @sbResponseBody
EXEC sp_OASetProperty @jResp, 'EmitCompact', 0
PRINT 'Response Body:'
EXEC sp_OAMethod @jResp, 'Emit', @sTmp0 OUT
PRINT @sTmp0
DECLARE @respStatusCode int
EXEC sp_OAGetProperty @resp, 'StatusCode', @respStatusCode OUT
PRINT 'Response Status Code = ' + @respStatusCode
IF @respStatusCode >= 400
BEGIN
PRINT 'Response Header:'
EXEC sp_OAGetProperty @resp, 'Header', @sTmp0 OUT
PRINT @sTmp0
PRINT 'Failed.'
EXEC @hr = sp_OADestroy @resp
EXEC @hr = sp_OADestroy @http
EXEC @hr = sp_OADestroy @queryParams
EXEC @hr = sp_OADestroy @sbResponseBody
EXEC @hr = sp_OADestroy @jResp
RETURN
END
EXEC @hr = sp_OADestroy @resp
-- Sample JSON response:
-- (Sample code for parsing the JSON response is shown below)
-- {
-- "after_cursor": "<string>",
-- "after_url": "<string>",
-- "audits": [
-- {
-- "author_id": "<integer>",
-- "created_at": "<dateTime>",
-- "events": [
-- {
-- "voluptate_edf": 37194901.82832828,
-- "dolor0": 61753613
-- },
-- {
-- "sedb2": false
-- }
-- ],
-- "id": "<integer>",
-- "metadata": {
-- "aute__": "proident aute qui culpa",
-- "ex_ae": "dolore Lorem labore ut"
-- },
-- "ticket_id": "<integer>",
-- "via": {
-- "channel": "<string>",
-- "source": {
-- "et_c59": 68912889
-- }
-- }
-- },
-- {
-- "author_id": "<integer>",
-- "created_at": "<dateTime>",
-- "events": [
-- {
-- "nostrud_fd6": -68241256.05178377
-- },
-- {
-- "ullamcoe": "ad",
-- "adipisicing_1": false
-- }
-- ],
-- "id": "<integer>",
-- "metadata": {
-- "veniam_689": -18333948.100650415,
-- "elit_2ab": "eu dolor deserunt consequat dolore"
-- },
-- "ticket_id": "<integer>",
-- "via": {
-- "channel": "<string>",
-- "source": {
-- "sint490": -68016605.99205834
-- }
-- }
-- }
-- ],
-- "before_cursor": "<string>",
-- "before_url": "<string>"
-- }
-- Sample code for parsing the JSON response...
-- Use this online tool to generate parsing code from sample JSON: Generate JSON Parsing Code
DECLARE @author_id nvarchar(4000)
DECLARE @created_at nvarchar(4000)
DECLARE @id nvarchar(4000)
DECLARE @Aute__ nvarchar(4000)
DECLARE @Ex_ae nvarchar(4000)
DECLARE @ticket_id nvarchar(4000)
DECLARE @Channel nvarchar(4000)
DECLARE @Et_c59 int
DECLARE @Veniam_689 nvarchar(4000)
DECLARE @Elit_2ab nvarchar(4000)
DECLARE @Sint490 nvarchar(4000)
DECLARE @j int
DECLARE @count_j int
DECLARE @voluptate_edf nvarchar(4000)
DECLARE @dolor0 int
DECLARE @sedb2 int
DECLARE @nostrud_fd6 nvarchar(4000)
DECLARE @ullamcoe nvarchar(4000)
DECLARE @adipisicing_1 int
DECLARE @after_cursor nvarchar(4000)
EXEC sp_OAMethod @jResp, 'StringOf', @after_cursor OUT, 'after_cursor'
DECLARE @after_url nvarchar(4000)
EXEC sp_OAMethod @jResp, 'StringOf', @after_url OUT, 'after_url'
DECLARE @before_cursor nvarchar(4000)
EXEC sp_OAMethod @jResp, 'StringOf', @before_cursor OUT, 'before_cursor'
DECLARE @before_url nvarchar(4000)
EXEC sp_OAMethod @jResp, 'StringOf', @before_url OUT, 'before_url'
DECLARE @i int
SELECT @i = 0
DECLARE @count_i int
EXEC sp_OAMethod @jResp, 'SizeOfArray', @count_i OUT, 'audits'
WHILE @i < @count_i
BEGIN
EXEC sp_OASetProperty @jResp, 'I', @i
EXEC sp_OAMethod @jResp, 'StringOf', @author_id OUT, 'audits[i].author_id'
EXEC sp_OAMethod @jResp, 'StringOf', @created_at OUT, 'audits[i].created_at'
EXEC sp_OAMethod @jResp, 'StringOf', @id OUT, 'audits[i].id'
EXEC sp_OAMethod @jResp, 'StringOf', @Aute__ OUT, 'audits[i].metadata.aute__'
EXEC sp_OAMethod @jResp, 'StringOf', @Ex_ae OUT, 'audits[i].metadata.ex_ae'
EXEC sp_OAMethod @jResp, 'StringOf', @ticket_id OUT, 'audits[i].ticket_id'
EXEC sp_OAMethod @jResp, 'StringOf', @Channel OUT, 'audits[i].via.channel'
EXEC sp_OAMethod @jResp, 'IntOf', @Et_c59 OUT, 'audits[i].via.source.et_c59'
EXEC sp_OAMethod @jResp, 'StringOf', @Veniam_689 OUT, 'audits[i].metadata.veniam_689'
EXEC sp_OAMethod @jResp, 'StringOf', @Elit_2ab OUT, 'audits[i].metadata.elit_2ab'
EXEC sp_OAMethod @jResp, 'StringOf', @Sint490 OUT, 'audits[i].via.source.sint490'
SELECT @j = 0
EXEC sp_OAMethod @jResp, 'SizeOfArray', @count_j OUT, 'audits[i].events'
WHILE @j < @count_j
BEGIN
EXEC sp_OASetProperty @jResp, 'J', @j
EXEC sp_OAMethod @jResp, 'StringOf', @voluptate_edf OUT, 'audits[i].events[j].voluptate_edf'
EXEC sp_OAMethod @jResp, 'IntOf', @dolor0 OUT, 'audits[i].events[j].dolor0'
EXEC sp_OAMethod @jResp, 'BoolOf', @sedb2 OUT, 'audits[i].events[j].sedb2'
EXEC sp_OAMethod @jResp, 'StringOf', @nostrud_fd6 OUT, 'audits[i].events[j].nostrud_fd6'
EXEC sp_OAMethod @jResp, 'StringOf', @ullamcoe OUT, 'audits[i].events[j].ullamcoe'
EXEC sp_OAMethod @jResp, 'BoolOf', @adipisicing_1 OUT, 'audits[i].events[j].adipisicing_1'
SELECT @j = @j + 1
END
SELECT @i = @i + 1
END
EXEC @hr = sp_OADestroy @http
EXEC @hr = sp_OADestroy @queryParams
EXEC @hr = sp_OADestroy @sbResponseBody
EXEC @hr = sp_OADestroy @jResp
END
GO
Curl Command
curl -u login:password -G -d "limit=%3Cinteger%3E"
-H "Accept: application/json"
https://example.zendesk.com/api/v2/ticket_audits
Postman Collection Item JSON
{
"name": "List All Ticket Audits",
"request": {
"method": "GET",
"header": [
{
"key": "Accept",
"value": "application/json"
}
],
"url": {
"raw": "{{baseUrl}}/api/v2/ticket_audits?limit=<integer>",
"host": [
"{{baseUrl}}"
],
"path": [
"api",
"v2",
"ticket_audits"
],
"query": [
{
"key": "limit",
"value": "<integer>",
"description": "Maximum number of results returned"
}
]
},
"description": "Returns ticket audits. Archived tickets are not included in the response. Use the [List Audits for a Ticket](#list-audits-for-a-ticket) endpoint to \nretrieve audit records for an archived ticket. To learn more about archived tickets, see [About archived tickets](https://support.zendesk.com/hc/en-us/articles/203657756).\n\nThis endpoint should not be used for capturing change data. When continually chasing the tail of a cursor, some records will be skipped. For this use case, use the [Incremental Ticket Event Export API](/api-reference/ticketing/ticket-management/incremental_exports/#incremental-ticket-event-export).\n\n#### Pagination\n\n- Cursor pagination\n\nSee [Pagination](/api-reference/introduction/pagination/).\n\nReturns a maximum of 100 records per page.\n\n#### Allowed For\n\n* Admins\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/ticket_audits?limit=<integer>",
"host": [
"{{baseUrl}}"
],
"path": [
"api",
"v2",
"ticket_audits"
],
"query": [
{
"key": "limit",
"value": "<integer>",
"description": "Maximum number of results returned"
}
]
}
},
"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 \"audits\": [\n {\n \"author_id\": \"<integer>\",\n \"created_at\": \"<dateTime>\",\n \"events\": [\n {\n \"voluptate_edf\": 37194901.82832828,\n \"dolor0\": 61753613\n },\n {\n \"sedb2\": false\n }\n ],\n \"id\": \"<integer>\",\n \"metadata\": {\n \"aute__\": \"proident aute qui culpa\",\n \"ex_ae\": \"dolore Lorem labore ut\"\n },\n \"ticket_id\": \"<integer>\",\n \"via\": {\n \"channel\": \"<string>\",\n \"source\": {\n \"et_c59\": 68912889\n }\n }\n },\n {\n \"author_id\": \"<integer>\",\n \"created_at\": \"<dateTime>\",\n \"events\": [\n {\n \"nostrud_fd6\": -68241256.05178377\n },\n {\n \"ullamcoe\": \"ad\",\n \"adipisicing_1\": false\n }\n ],\n \"id\": \"<integer>\",\n \"metadata\": {\n \"veniam_689\": -18333948.100650415,\n \"elit_2ab\": \"eu dolor deserunt consequat dolore\"\n },\n \"ticket_id\": \"<integer>\",\n \"via\": {\n \"channel\": \"<string>\",\n \"source\": {\n \"sint490\": -68016605.99205834\n }\n }\n }\n ],\n \"before_cursor\": \"<string>\",\n \"before_url\": \"<string>\"\n}"
}
]
}