Using Created and Updated Date for Tickets API
AnsweredI'm importing some tickets from a legacy ticketing system and I'm trying to pass in the original created and updated dates on the imported tickets. Also, I'm running a Python script to do the import, pulling from an Excel document. The Created and Updated dates are stored as such below in Excel.
I pull these into my Python script and convert to a string for both 'created_at' and 'updated_at' in my API call, but it's putting in today's date/time for both values by default instead of the values from my spreadsheet.
Any thoughts here? It's probably a conversion that needs to take place, but I can't figure it out.
-
Hi Chris!
The json date format for Zendesk APIs is:
YYY-MM-DDTHH-mm-ssZlike:
"created_at":"2022-06-16T13:36:05Z"You will therefore have to reformat your date in the json.
Friendships,
Serge. -
Thoughts on the syntax/format to do that?
-
Here is an example of python code to format the date correctly:
At the beginning of the python code:
import datetime
Durring the code :
Zendesk_Created_time = CreatedTime.strftime('%Y-%m-%dT%H:%M:%SZ')
Zendesk_Updated_time = UpdatedTime.strftime('%Y-%m-%dT%H:%M:%SZ')
Then in json :
created_at :
Zendesk_Created_time,
updated_at :Zendesk_Updated_time,
...friendships,
Serge.
-
Thanks that helped, but I'm wondering if 'created_at' and 'updated_at' are even supported for creating new tickets via the Ticket API? I have my formatting correct (see below), but it continues to set each date within the ticket to today's date/time.
{"ticket": {"subject": "C&L Platform Request - Test","requester": "cgreen@meazurelearning.com","tags": "import","status": "open","created_at": "2022-06-15T10:01:00","updated_at": "2022-06-15T10:01:00","brand_id": 7708479157517,"group_id": 8298833890701,"ticket_form_id": 8297974053005,"comment": {"body": "testing","public": "true"},"custom_fields": [{"id": 8298500333837,"value": "Connect"},{"id": 360043217471,"value": "ABC"},{"id": 8298331661197,"value": "priority_3_standard"},{"id": 8298425523469,"value": "c_l_support_dev"},{"id": 8550445685389,"value": ""}]}} -
Indeed, these fields may be read-only.
Maybe you can create custom fields in date format to inject this information.
Friendships,
Serge. -
Hello Chris Green and Serge BERTAINA DUBOIS
For creating legacy tickets, please use the Ticket Import API which would allow you to set the created_at date for the legacy tickets.
-
POST /api/v2/imports/tickets
- This endpoint is used to create tickets with created_at date.
Please review the documentation I have linked above if you have any questions. Thanks. -
Please sign in to leave a comment.
6 Comments