How to update custom field values using API
已于 2021年10月14日 发布
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 条评论
CJ Johnson
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
Frank Taylor
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.
0
CJ Johnson
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:
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
登录再写评论。