Error Creating Ticket using API with Python

  • Used Zammad version: 5.2.3
  • Used Zammad installation type: package
  • Operating system: Debian (Server), Windows 10 (Client)
  • Browser + version: Google Chrome Version 101.0.4951.67 (Official Build) (64-bit)

Expected behavior:

Creating a ticket with a simple template modificated from the one found here:

https://docs.zammad.org/en/latest/api/ticket/index.html#create

Using Python requests to post it. It does not work, I tried using Postman and it worked properly so I suppose the payload is correct.

Actual behavior:

I receive 500 response with the following reason:

{“error”:“no implicit conversion of Symbol into Integer”}

Here is the complete python script to create the ticket:

#! /usr/bin/python3

import json, requests

token = '5j6s....'
auth  = f'Token token={token}'

def create_ticket():
    url = 'http://172.18.0.70/api/v1/tickets'
    new_ticket = {
        "title": "Help me!",
        "group": "PRUEBAS_SOPORTE",
        "customer": "fpardo@example.com",
        "article": {
            "subject": "My subject",
            "body": "I am a message!",
            "type": "note",
            "internal": False
   }
}
    req = requests.post(url, headers={'Authorization':  auth} ,data=new_ticket)
    print (req.status_code)
    print(f'{req.text}')
create_ticket()

Adding also production.log results in case it helps:

Any advice would be appreciated.

Best Regards,

This is the issue.
Ruby knows true and false.
You’re using python termology here.

If that’s not helping this may also be caused by the used libary.

1 Like

Thank you for the response, actually i made is work using a different method to create the json:

import requests
token = '5j6so....'
auth  = f'Token token={token}'
r = requests.post('http://172.18.0.70/api/v1/tickets', headers={'Authorization':  auth} , json={
    "title": "Help Me!",
    "group": "PRUEBAS_SOPORTE",
    "customer": "fpardo@example.com",
    "article": {
        "subject": "My subject",
        "body": "I am a message!",
        "type": "note",
        "internal": False
    }
}
)
print(f"Status Code: {r.status_code}")

Hopefully this may help others, many thanks for the help! :smiley:

2 Likes

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