Type/Priority/Custom fields not set when creating request
BeantwortetI'm attempting to add some custom fields to our tickets (both Text) when created through the requests API.
I'm POSTing the following data (from Javascript) to https://oursite.zendesk.com/api/v2/requests.json
{
request:{
type: 'incident',
priority: 'high',
requester:{name:'John Doe',email:'john.doe@email.com'},
subject: 'Something bad happened!',
comment:{
body: 'Can you look into this?',
},
custom_fields: [
{ id: 8296782846740, value: 'custom 1'},
{ id: 8296695964692, value: 'custom 2'},
]
}
}
The requester, subject, and comment all show up on the ticket fine, but the type, priority, and custom fields are not being set (they just become the defaults, which in this case is low for priorty, not set for type, and the custom fields are empty)
I'm referencing the Create Request documentation, and I think that should be the right format?
-
This endpoint is a real pain about not telling you when things aren't formatted the way it needs. You will need to add quotes to a lot of places to get this to work, and change some of your single quotes, to doubles. Try this:
{
"request":{
"type": "incident",
"priority": "high",
"requester":{"name":"John Doe","email":"john.doe@email.com"},
"subject": "Something bad happened!",
"comment":{
"body": "Can you look into this?",
},
"custom_fields": [
{ "id": "8296782846740", "value": "custom 1"},
{ "id": "8296695964692", "value": "custom 2"},
]
}To figure out if you have syntax issues, I recommend the free products Sublime, or Visual Studio, which let you paste in code, and tell it what flavor it is, and then it highlights any problems:
Additionally, Postman, a GUI interface for interacting with APIs, has a built in syntax checker that has helped me find stray commas and the like before I send, all the time. That can make it a little quicker/easier to deal with the API returning a syntax error, because the sending/checking/receiving it all in the same window: -
CJ Johnson Thanks for the reply!
Sorry, I should have clarified, this is a Javascript object that's converted to JSON eventually by our request handler (hence no quotes on keys; single quotes are just the codebase style)
This is the JSON data being sent out:{
"request": {
"type": "incident",
"priority": "high",
"custom_fields": [
{
"id": 8296782846740,
"value": "custom 1"
},
{
"id": 8296695964692,
"value": "custom 2'"
}
],
"requester": {
"name": "John Doe",
"email": "john.doe@email.com"
},
"subject": "Something bad happened!",
"comment": {
"body": "Can you look into this?"
}
}
} -
Hi Jared Petchell,
Perhaps check from admin center or ticket fields end point if those fields are editable by end users?
-
Ahmed Zaid
That was it! Those fields populate correctly now. Thanks!
We don't want these custom fields showing up to the user when submitting a request though, so I'll look into other ways of adding the info (possible adding an internal note) -
Glad it worked. I believe if you remove the fields from the ticket form you can still populate them without exposing them to the end user. However, they will not be visible to agents. My ideal solution would be populating those fields with a trigger after request is created instead.
Bitte melden Sie sich an, um einen Kommentar zu hinterlassen.
5 Kommentare