Error creating ticket via API

Hi,
Trying to create a ticket with an API call I have a 500 Internal Server Error with {“error”:“no implicit conversion of Symbol into Integer”}.
Ticket was created but empty and in production log i found the anomaly in article part where there is only the last parameter.
I’ve marked in bold the anomaly.

Zammad Version: 5.0.x (retrived via VERSION file)
Installed via: Package
OS: AlmaLinux release 8.5 (server) - Ubuntu 20.04 (client)
Browser: Python API call

Actual behavior:

Production Log extract:

I, [2022-08-23T07:46:42.318366 #707-1302918920]  INFO -- : execute Job.run (try_count 0)...
I, [2022-08-23T07:46:42.361253 #707-1302918920]  INFO -- : ended Job.run took: 0.050002071 seconds.
I, [2022-08-23T07:46:45.193708 #712-91720340]  INFO -- : Started POST "/api/v1/tickets" for 10.121.243.45 at 2022-08-23 07:46:45 +0000
I, [2022-08-23T07:46:45.196405 #712-91720340]  INFO -- : Processing by TicketsController#create as */*
I, [2022-08-23T07:46:45.196465 #712-91720340]  INFO -- :   Parameters: {**"title"=>"Message Title", "group"=>"[L2] IT Support", "customer"=>"abc@xyz.com", "article"=>"internal"**}
E, [2022-08-23T07:46:45.513485 #712-91720340] ERROR -- : no implicit conversion of Symbol into Integer (TypeError)

Steps to reproduce the behavior:

Python Code:

token = "MyToken"
auth  = f"Token token={token}"


def create_ticket():
    url = 'https://myzammad.mydomain.com/api/v1/tickets'
    new_ticket = {
        "title": "Message Title",
        "group": "[L2] IT Support",
        "customer": "abc@xyz.com",
        "article": {
            "subject": "Message Subject",
            "body": "Message Body",
            "type": "",
            **"internal": False**
        }
    }

    print("----\n")
    print(json.dumps(new_ticket, indent=2))
    print("----\n")


    req = requests.post(url, headers={'Authorization' : auth}, data = new_ticket)

    if (req.status_code != 201):
        print(f"1... Error: {req.status_code} {req.reason}")
        print(f"2... {req.text}")
        print(req.json())
        return(0)

create_ticket()

Your payload in general is faulty.
If you have no value for an attribute, consider not providing it at all.

You can find a sample payload here:
https://docs.zammad.org/en/latest/api/ticket/index.html#create

Not sure which attribute actually is of type symbol and subject to be converted here.
Might help to see the actual payload.

This topic was automatically closed 120 days after the last reply. New replies are no longer allowed.