Recent searches


No recent searches

'Record validation errors' when attempting to change a ticket's status to a custom status with my custom program.



Posted Oct 01, 2023

I'm making a python program to help automate my workload. I'm using the Zenpy program to do it. The code will run and execute my custom functions as expected ONLY if the status line reads:

ticket.status = 'open' 

It also works if the status is set to one of the other Zendesk default statuses (open, pending, solved).

However when I try to replace 'open' with my custom status titled 'Athena Reply' (which for when she replies to a ticket before me), I get the following error message:

{"error": "RecordInvalid", "description": "Record validation errors", "details": {"custom_status_id": [{"description": "Custom status is invalid", "error": "InvalidValue"}]}}

And this happens if I put in the name of the status ('Athena Reply') in either matching case as it appears on Zendesk, or lower case too. Also, after querying the API for the custom status ID, which is 19218.. or something, a very long series of numbers, the same error is returned.

Moreover, I have extensively confirmed with a very kind Zendesk support agent that the custom status ID was correct, he gave it to me, and that the information endpoint was correctly accessible.

 

Here is my test file I'm using to validate the functionality before integrating it into my full program:

from zenpy import Zenpy

from zenpy.lib.api_objects import Comment

import yaml

# Initialize the Zenpy client

with open('config.yaml', 'r') as cf:

    config = yaml.safe_load(cf)

creds = {

    'email': config['Zendesk_Email'],

    'token': config['Zendesk_Key'],

    'subdomain': config['Zendesk_Subdomain']

}

zenpy_client = Zenpy(**creds)

def do_the_thing():

    print("Tme to do that thing!")

    for ticket in zenpy_client.search_export(type='ticket', status='new', brand="Meetn"):

        ticket_text = ticket.description

        print("Ticket said: " + ticket_text)

        Ask_Athena = handoff_to_Athena()

        print("Athena said: " + Ask_Athena)

       

        ticket.comment = Comment(body=Ask_Athena, public=False)

        #ticket.status = '19218874479771'

        ticket.status = 'Athena Reply'

        zenpy_client.tickets.update(ticket)

do_the_thing()
As you can see in line 25/26 those are where the error is being triggers when line 27 runs. As mentioned above, when I write "ticket.status = 'open'" the program executes without error, closes, and the ticket in Zendesk is appropriately changed as expected. But not with the custom status or the custom status's ID.

0

2

2 comments

Have you tried setting ticket.custom_status_id with the custom status id of Athena Reply?

0


I tried running this:

    t = zenpy_client.tickets(id=200254)

    #ticket_text = t.description

    ticket_text = t.custom_status_id

    print(ticket_text)
#200254 is a ticket I created to test this and I am able to extract the description as expected. I manually set the ticket status to 'Athena Reply' to see what it will say when running your

Having it print out the "ticket.custom_status_id" returned the same "19218874479771" number that was revealed in the API with the other query and given to me by the Zendesk support agent.
So the question remains, why does "ticket.status = 'Athena Reply'" and "ticket.status = '19218874479771'" return the error message?
 

0


Please sign in to leave a comment.

Didn't find what you're looking for?

New post