Recent searches


No recent searches

How to update custom field values using API



Posted Oct 14, 2021

We are trying to use Zendesk tickets to track fraud costs in our organization. I have three custom fields "attempted", "recovered", and "loss". Evidently Zendesk will not perform the calculation internally, so I am using the ticket API to retrieve the values, perform the calculation (attempt - recovery = loss), and then use the ticket API to update the "loss" custom field with the value.

I am using the following API according to the documentation, but it is not populating the custom field with the new value.

put https://{domain name}.zendesk.com/api/v2/tickets/{ticket number}.json -v -u {username}/token:{API Key} -H "Content-Type: application/json" -d '{ "ticket": {"custom fields": [{"id": 360048278251, "value": 999}]}}'

The output from this statement seems to be the original ticket values and not the updated values. When I look at the ticket in Zendesk this field is not updated.

How do I update/change the custom field in a ticket?


1

13

13 comments

I think you have some line breaks (\ symbol) missing that indicate a new line in your curl command, but also some missing flags. I'll be totally honest, I am completely self-taught with JSON so this may not be the perfect/prettiest syntax, but it worked for me. I also typically use Postman, and let Postman prettify the JSON for the ticket portion,  but I did test this in this format, on the command line as well, and it worked: 

curl https://{domain}.zendesk.com/api/v2/tickets/{ticket_id}.json \
-H "Content-Type: application/json" \
-d '{
"ticket": {
"custom_fields": [
{
"id": 360048278251,
"value": "9999"
}
]
}
}' \
-v -u {username}/token:{API key} -X PUT

The \ means "Hey this command is not done yet, there's at least one more line", so that curl doesn't just stop reading and fire after getting the first flag and value for it, which I think was the main issue you were hitting. 

1


I have tried running this in Microsoft PowerApp Flow, curl, and Postman. All three fail to update the custom field. When I review the output from Flow and Postman the custom field I am attempting to update still has a value of Null rather than the value I am attempting to set.

I did notice that you put quote marks around the value, so I tried that as well. Unfortunately the results did not change. That field is defined as a Decimal field.

Here is the Postman body, which is the same as the PowerApp Flow body.

{
  "ticket":{
    "custom fields": [
      {
        "id": 360048278251,
        "value": 999
      }
    ]
  }
}
 

0


Ooh, the Decimal field type! I just tried this again with a Decimal field instead of Numeric -- If there's no decimal in the number, it looks like it doesn't update the field, I think that might be the last missing piece! 99.99  worked (with the quotes) as a value for me. 

0


There is one custom field, and in the custom field, we have added over 8000 different tags.

Now we are investigating to use API to update the whole list

a) Remove some tags and keep others

b) Add new tags without affecting existing tags

How can we do?

0


image avatar

Eric Nelson

Zendesk Developer Advocacy

Hey there,

You'll want to write a script that after listing all of the ticket field options > loops through the options and pops them into a new array of objects for the ones you'd like to keep > then add in the new ones into the cleaned array. Finally use the update ticket field api to update the field. 
 
Hope this helps,

0


HI Team

In the customer  UI view page how can I add a one more column to display the content is there in the customer field 

Any suggestion

Regards

 

 

0


image avatar

Erica Girges

Zendesk Developer Advocacy

Hi Krishnamurthy,
 
Just to confirm are you looking to make the custom ticket field data visible to your customers as well?
 
Best,
 
Erica

0


HI Erica

Yes that is correct. Any suggestion on it

Regards

Krishnamurthy

0


image avatar

Erica Girges

Zendesk Developer Advocacy

Thank you for confirming! 

You can easily change visibility and permissions for ticket fields (including custom ones) via the Admin Center as shown below.

 

Hope this helps!

Erica

0


Erica

Tried your suggestion and its does not help

 

Enclosing the screen shot which is visible to customer once they login to the portal and as you see it only shows  ID, Subject, Created, Last activity, Status  and not able to add custom field name" Ticket Type" to show  in the UI

 

0


image avatar

Erica Girges

Zendesk Developer Advocacy

Hi Krishnamurthy,
 
Apologies for the confusion. Unfortunately, the custom ticket field won't show on this page however, it will be visible to the customers once a request/ticket is open via the right hand fields/values.
 
Best,
 
Erica

0


Saben como puedo ocultar campos de la modal cuando realizas ediciones masivas?? Ya que tengo campos dentro del ticket que no todos estan visibles ya que tengo formularios condicionados (visibilidad de campos basados en otros campos), pero al realizar la edicion masiva, me muestra todos los campos,a bsolutamente los campos que no estan visibles en el ticket?

 

Alguien pude apoyarme con esto, o ver si es posible?

0


image avatar

Greg Katechis

Zendesk Developer Advocacy

Hi Marco! We do not have a way to hide any fields in the bulk edit modal. 

0


Please sign in to leave a comment.

Didn't find what you're looking for?

New post