Arsalan Rana
Arsalan Rana

Reputation: 1

How to update the ticket field using API

Can someday jump on this and help me to update the ticket field (ticket is already submitted), the targeted field is a custom-field which I need to update it using the Zendesk API,

Can this is possible using Zendesk API?

Thank You

Upvotes: 0

Views: 3784

Answers (2)

Gary Kester
Gary Kester

Reputation: 1

Just a bit more help. You can get a list of all custom field ids as follows:

const testFields = await client.get("ticketFields")
console.log(testFields)

I'm using zafCLient to update custom ticket fields straight away but that's not working for me. - client.request

The request goes trough as a PUT request. If I add a comment the same way it works fine but not updating a ticket field

Upvotes: 0

Karun
Karun

Reputation: 304

Update - Using Zendesk Api Endpoint

Zendesk Api Update Ticket is what you need to hit with the payload as described here:

    {
        ticket: {
            custom_fields: [{ "id": 25356371, "value": "something"}]          
        }
    }

Old Answer (using zafClient)

If you're trying this from Sidebar app and utilizing zafClient then its pretty straightforward. Example here and below

client.set('ticket.customField:fieldName', value) 

If you're trying this with Zendesk rest api then you can utilize this Update Ticket endpoint to update the value of any Custom-Field present in that ticket.

Steps to update:

  1. get custom-field's id
  2. get ticket id
  3. Hit update ticket api with following JSON payload

{
    ticket: {
        custom_fields: [{id: <custom_field_id>, value: 'hurray!'}]
    },
}

Upvotes: 3

Related Questions