1

My goal is to create a ticket in Zammad using the API and then to update it (for.

the reference for such basic tasks is here

I am using Postman to send requests.

I use the bearer token authentication, the token has been generated for a user who is ticket.agent (and he is admin too).

I manage to succesfully create a ticket by doing a post request to

https://myzammadinstance.com/api/v1/tickets

and with this body:

{
    "title": "Ticket generated from API - my test",
    "group": "Users",
    "article": {
        "subject": "My Subject",
        "body": "My body",
        "type": "note",
        "internal": false
    },
    "customer": "my@email.address",
    "user": "my@email.address",
    "note": "my notes"
}

This succesfully creates a ticket (with a given ID, let's say 1990).

Now i would like to update this ticket, so "replying from API".

I do a post request to

https://myzammadinstance.com/api/v1/tickets

and with this body:

{
  "id": 1990,
  "title": "updated title",
  "group": "Users",
  "state": "open",
  "customer_id": 12,
  "priority": "3 high",
  "article": {
    "subject": "some subject of update",
    "body": "some message of update"
  }
}

This executes but does not append a reply to my ticket 1990 but it generates a new ticket (with id 1991 and title "updated title").

I do not want to create a new ticket but just reply to an existing ticket.

May i misunderstood something but i double checked many times the documentation and the request body.

Anyone could give an hand please?

UPDATE: as stated in the comments is seems i should use https://myzammadinstance.com/api/v1/tickets/1990

but this does not work: a new ticket is not created but the response has an error:

{
    "error": "No route matches [POST] /api/v1/tickets/1990"
}

SOLUTION

The problem was in PUT vs POST, by using PUT and this endpoint

https://myzammadinstance.com/api/v1/tickets/1990

i managed to reply to the ticket.

UnDiUdin
  • 14,924
  • 39
  • 151
  • 249
  • Would you not use this endpoint to update the ticket `PUT /api/v1/tickets/{id}` - https://docs.zammad.org/en/latest/api/ticket.html#update – Danny Dainton Jun 05 '20 at 12:50
  • thanks for the reply. i am not expert enough likely, How am i supposed to interpret `{id}`? I tried with `PUT /api/v1/tickets/1990` but it replies "No route matches [POST] /api/v1/tickets/1990". Moreover why should i use the id both in the endpoint and in the body? Thanks! – UnDiUdin Jun 05 '20 at 13:03
  • i appended an UPDATE section to the question – UnDiUdin Jun 05 '20 at 13:10
  • Have you change the method to `PUT` - Not sure why it would return a message with `POST` in it. I don't own or have ever worked with this API, I just read the docs you attached :D – Danny Dainton Jun 05 '20 at 13:12
  • Yes I reached the same conclusion by reading the docs once more. `PUT` was the solution. Thanks! – UnDiUdin Jun 05 '20 at 13:16
  • That's why I added that method to the comment :D – Danny Dainton Jun 05 '20 at 13:17

1 Answers1

1

To update the ticket you would need to use this endpoint:

PUT /api/v1/tickets/{id}

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

Danny Dainton
  • 23,069
  • 6
  • 67
  • 80