Stuck with ticket creation via API

  • Used Zammad version: 6.3
  • Used Zammad installation type: package
  • Operating system: Ubuntu 22.04
  • Browser + version: Chrome

Unfortunately, I can’t get any further with the creation of tickets via API (via curl). My message is “{”error“: ‘Not authorized (token)!’, ‘error_human’: ‘Not authorized (token)!’}”. My user is admin and agent, has the right “ticket.agent”. I guess I have to make a setting under “Access Token”, but I can’t find out which point(s) I have to activate. Currently these three items are enabled: TICKET, TICKET_PRIORITY and TICKET_STATE (I tried to activate all points too, but it didn’t work either).

I am currently using this command. API, e-mail and URL are placeholders here:

curl -X POST “https://URL/api/v1/tickets” -H “Authorization: Bearer API-KEY” -H “Content-Type: application/json” -d ‘{“title”: “Ticket via API”, “group_id”: 5, “customer”: {“email”: “EMAIL ADDRESS”, “firstname”: “Jane”, “lastname”: “Doe”}, “state”: “new”, “priority”: “2”, “article”: {“subject”: “Ticket via API”, “body”: “Test-Tickt via API. ”, “type”: “note”, “internal”: false }}’

It would be great if you could help me. Unfortunately I’m not super-fit when it comes to APIs.

Thanks a million.

Hi @anpeter. Do you have access to the used group?

And, please, read Introduction — Zammad System Documentation documentation. Thanks.

Yes, I have access to the used group via UI. And yes, I have read the documentation unfortunately I am not very familiar with API and programming.

Thanks for support.

Well, it’s all written down, you’re just using it in a wrong way.

Okay, then I’ll read the document again. Hopefully I’ll find what I’m doing wrong :wink:

Create an access token for your purpose in the profile settings for the user that should be used for the API call, and use this token for the authentication.

Exactly. That’s how I read it and that’s how I understood it. My problem is, what should I enter in the access token? There are many checkboxes here that can be ticked. So far I have activated TICKET, TICKET_PRIORITY and TICKET_STATE. I have also activated all of them, but always received the above message.

Maybe you should make a screenshot, because there a different sections in general for admin and agent area.

You’re not reading/understanding the documentation, I guess. You’re using an access token to create a ticket, but why are you trying to authenticate against Zammad as a third-party application?

I mean Profil => Token-Zugriff => Hinzufügen eines persönlichen Zugangs-Tokens => Erstellen

Am I on the wrong track?

Okay, I think I have to read the documentation again. First contact with APIs.

1 Like

Any luck so far, @anpeter? :slight_smile:

Unfortunately not :-(. When I use curl -X GET “URL/api/v1/groups/5” -H “Authorization: Token token=API-KEY” I get the infos as json.

But if I try to create a ticket with curl -X POST “URL/api/v1/tickets” -H “Authorization: Token token=API-KEY” -H “Content-Type: application/json” -d ‘{“title”: “Ticket per API”, “group_id”: 5, “customer”: {“email”: “EMAIL”, “firstname”: “Jane”, “lastname”: “Doe”}, “state”: “new”, “priority”: “2”, “article”: { “subject”: “Ticket per API”, “body”: “Dies ist ein Test-Ticket, das per API erstellt wurde.”, “type”: “note”, “internal”: false }}’ I get the massage {“error”:“Not authorized (token)!”,“error_human”:“Not authorized (token)!”}.

I am on the zammad server it self. No 3rd party applications to authenticate against Zammad :slight_smile:

At " Persönliche Zugangs-Token" I got the rights like “admin, admin.ticket, admin.ticket_priority, admin.ticket_state”

agent.ticket is the permission you need. If you’d look at the documentation, you’d know what permissions are required.

Guys, I am so grateful. It works. I have read all this, but then probably didn’t combine it correctly. Very good. Many thanks to you.

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