Recent searches


No recent searches

Cannot set 'via' fields when creating tickets using the API



Posted Oct 25, 2022

I am trying to create tickets using the API but cannot seem to set the 'via' properties on ticket comments.

My use case is that I'm importing existing tickets from another product into Zendesk. These tickets were created automatically in response to an incoming email. So I think it makes sense to create a new ticket in Zendesk with the first comment containing the content of the email and having the 'via' properties on that comment contain the email info (e.g. from/to addresses & names)

The docs seem to suggest this is possible, but I am getting errors on ticket creation: `unpermitted_keys: ["ticket.comment.via.channel", "ticket.comment.via.source.to.address" ...]`

Example:

params = {:subject=>"test subject",
:requester_id=>12345,
:comment=> {
:html_body=> "test email body",
:author_id=>12345,
:via=> {
:channel=>"email",
:source=> {
:to=> {
:address=>"support@mycompany.com"
},
:from=> {
:address=>"customer@gmail.com",
:name=>"Customer name"}
}
},
:uploads=>[]},
:status=>"closed"} ZendeskAPI::Ticket.create!(client, params)


Any ideas on what I'm doing wrong?


1

6

6 comments

Also noticed that if I set the 'via' object on the Ticket itself (rather than the ticket comment) it doesn't complain and appears to succeed just fine. 

However, it seems to ignore whatever value I've set. The channel always ends up as 'api'

0


I also have a scenario where i would like to change the 'to' value of the 'via' object in ticket comment - via Request API. 

I would like to create a ticket (request) on behalf of the end user setting 'to' to the support mail address. Instead the 'to' value in 'via' object is always set to the author of the ticket (end user). And the ticket looks like the end user is addressing ticket to himself :/ changing the recipient of the ticket (request) is not changing anything

0


image avatar

Erica Girges

Zendesk Developer Advocacy

Hi James, 
 
It isn't suggested to update these fields after ticket creation. However, since you are creating a new ticket when setting these values it should set them accordingly. Let me go ahead and take a further look and see what might causing this.
 
Best, 
 
Erica

1


Hi Erica,

That's right I'm only interested in setting these values on ticket creation. Thanks for looking into it

0


I've tried using the import end point to create the ticket. It doesn't error, but it also ignores the 'via' parameter

0


image avatar

Erica Girges

Zendesk Developer Advocacy

Hi James, 

After taking a further look, these fields are automatically being set on our end at the time the request is made. This is to prevent issues of ticket data being tampered with since this specific field holds the origin of the ticket. This sort of checks and balances on our end results in the via property fields not being updated/set with parameters passed with these endpoints.

The docs don't list this property as Read-only because there are specific product instances where it's necessary to set/change these values via endpoint. For those instances alone it is editable. Unfortunately, for this use-case and the product being used there isn't an endpoint that would allow for this. I recognize that this could be confusing since it isn't explicitly stated in our docs. I'm going to reach out to get that updated and provide more clarity around changes to the via object.

If you were looking to provide that info with the ticket data you could look into creating a custom ticket field to store that in.

I also recommend still using the Ticket Import endpoint for moving your tickets over to Zendesk.

Best,

Erica

0


Please sign in to leave a comment.

Didn't find what you're looking for?

New post