Creating a ticket with extra fields through the API


  • Jeremy Heath

    Ok ive managed to get this working but the part im not understanding is it will not let me add any extra sections or info

    If i try and change the Type field for e.g. it never appears in the ticket

    Im using the method from the original post , "type": "problem" 

    any help?


  • Andrew Dietrich

    Hi Jeremy,

    I've taken a look at some logs of the requests you are sending in and it looks like you are sending in a lot of this information, such as the ticket type and custom fields, within the comment object. The comment object should only contain the body and any uploads.

    I am also seeing that with custom fields you are referring to the fields via their title, not their field ID. Please see the examples here:

    Hope this helps!

  • Jeremy Heath

    Hi Andrew 

    Are uploads attachments to the post?


    The main issue im having is where to place the section you mention for e.g

    "custom_fields": [{"id": 21938362, "value": "hd_3000"}]

    where does it fit within the code i posted?Ive tried moving it into other sections , in between brackets, further to the front but i cant get it to work.


    where should it be added?

  • Andrew Dietrich

    Hi Jeremy,

    Yep, uploads are attached files.

    The custom fields array can be placed anywhere in the ticket/request object, as long as it's not contained within anything else (i.e. it needs to be on the "top level"). So you could do something like this:


    curl https://**** \ -d '{"request": { "custom_fields": [{"id": 21938362, "value": "hd_3000"}],  "subject": "Help!" , "comment": {"body": "My printer is on fire!", "uploads": [...] }}}' \ -v -u *****/token:************* -X POST -H "Content-Type: application/json"

  • Jeremy Heath

    Hi there

    Right this is what i tried before in my test attempts but it fails

    curl https://********** -d '{"request": { "custom_fields": [{"id": 360005187612, "value": "Problems"}], {"subject": "Help!", "comment": {"body": "My printer is on fire!"}}}' -v -u ********/token:********** -X POST -H "Content-Type: application/json" 

    Now that is aimed at the Type field which should work as its a standard field.

    < expect-ct: max-age=604800, report-uri="https://report-*******expect-ct"
    < server: cloudflare
    < cf-ray: 475eec535a5d6b6d-LHR
    * Connection #0 to host d******* left intact
    {"error":"Unprocessable Entity","message":"Server could not parse JSON"}

    Thats the last bit of the error i get from the bash terminal

    I tried with a field i had created for testing and i get the same error

    Everytime i change the line of code i get the error

    Any thoughts?

  • Andrew Dietrich

    Hi Jeremy,

    Looks like you added an extra { bracket before subject. Subject should be contained directly within the request object, so you can just delete it and the JSON should be parsable now.

    You can use this site to validate your JSON:


Please sign in to leave a comment.

Powered by Zendesk