Forums/Community/Zendesk API

Answered

Creating a ticket with requester as submitter through the v2 API

Ville Vatén
asked this on May 11, 2012 00:59

Hi,

 

Previously we sent support tickets to Zendesk via email by forging the "From"-field to the original requestor. This resulted in a submitter AND the requestor being the same. This was nice since the Zendesk email notifications were from the original requestor and the emails showed relevant information in the From field.

Now, since the email delivery was unreliable, we decided to move to the Zendesk REST API.

However,

curl https://subdomain.zendesk.com/api/v2/tickets.json \
-d "{\"ticket\":{\"subject\":\"TEST TICKET\",\"requester\":{\"name\":\"John Doe\",\"email\":\"somebody@gmail.com\"}, \"description\":\"TEST TICKET\nby John\"}}" \
-H "Content-Type: application/json" \
-v -u agentemail/token:apitoken

creates a ticket which has requestor as somebody@gmail.com, but submitter as "agentemail". We have now tons of notification emails from the 'agentemail'.

AND:

curl https://subdomain.zendesk.com/api/v2/tickets.json \
-d "{\"ticket\":{\"subject\":\"TEST TICKET\",\"requester\":{\"name\":\"John Doe\",\"email\":\"somebody@gmail.com\"}, \"description\":\"TEST TICKET\nby John\"}}" \
-H "Content-Type: application/json" \
-H "X-On-Behalf-Of: somebody@gmail.com" \
-v -u agentemail/token:apitoken

fails as 403 Forbidden.

The question is, how to get the same requestor as the submitter of the ticket through the API when creating a new ticket on behalf of user that we don't know if he/she exists yet?

 

Best,

- Ville

 

 

Comments

User photo
Rob Eyre
bookdepository

Somewhat related to this, I'd like to be able to add comments from specific authors to tickets via the API.  I've tried setting 'author_id' here:

{"ticket":{"comment":{"public":false,"value":"Bar"},"author_id":1234546}}

and here:

{"ticket":{"comment":{"public":false,"value":"Bar","author_id":123456}}}

but it is silently ignored, and instead the comment is added with the API user as the author.

Any ideas?

Thanks

-Rob

August 08, 2012 05:01
User photo
Ted Barnum
Zendesk

Both the submitter_id and author_id are Read Only fields, and so can not be set.

The X-On-Behalf-Of: Header will not work for Agents assuming end users, as there is no call open directly to end users in the V2 API.

Our Developers are working on something for the V2 API to allow something like creating requests on behalf of an end user in the V1 API, and it is hoped to be out in the near future.

 

August 13, 2012 17:07
User photo
Steven Yan
Product Manager
Check Answer

Hi everyone, please see our new Requests API: https://support.zendesk.com/entries/21964887-comment-as-the-custome...  This API is intended to allow you to create or update tickets as an end-user and replaces the X-On-Behalf-Of behavior from API v1.

September 06, 2012 00:51
User photo
Nacer Laradji

I have the same issue with the new comment restriction, i can't add a author_id or submitter_id or requester_id  in v2.

So how can a Admin can add a comment in the name of one user now ? 

September 28, 2012 00:46
User photo
Joe Van Dyk
tanga

I'm also having problems. I'd like to have a form on my site where a user comes in, types in their email address and their problem, and I'd submit the form to Zendesk. I can't figure out how to create the ticket and have it appear as if they made it. They may or may not be in the zendesk system already.

November 02, 2012 21:39
User photo
DeVaris Brown
Zendesk

Hey Joe! Have you seen the documentation here: http://developer.zendesk.com/documentation/rest_api/tickets.html#cr...

I think this answers your question. Just pass in the value from the email field into the requester:email field in your JSON and it will create the ticket and sends a signup email to the new user. If the user email address already exists, it will add this ticket to their account.

November 07, 2012 12:44
User photo
Joel P
dataresearchgroup

That is an incomplete solution. See these two articles I created:

https://support.zendesk.com/entries/22135701-api-create-end-users-t...

https://support.zendesk.com/entries/22547116-requestor-vs-submitter

When you use the tickets.json end point, the "submitter" is the agent whose credentials were used for authentication. Zendesk shows this agent as person who entered the comment (it does not even show "on behalf of" anymore). 

I need a way to create tickets that are both Submitted AND Requested by a new end-user.

December 11, 2012 09:57
User photo
DeVaris Brown
Zendesk

@Joel are you talking about in the agent interface? We've addressed this in the API level, but the agent interface has yet to reflect this. It's a known bug that we are fixing in an upcoming release.

December 11, 2012 10:52
User photo
Joel P
dataresearchgroup

No, I'm talking about the API. I just tried submitting a test request using the method described at:

https://support.zendesk.com/entries/21964887-comment-as-the-custome...

However, if the end-user email used to authenticate isn't already in Zendesk I get a Unauthorized error "Couldn't authenticate you".

December 12, 2012 05:51
User photo
KK
lesarion

this solution is really an incomplete solution.

i like to set submitter and requester. both are ignored when i am logging in over the api as zendesk owner.

i like to do this without use the credentials of my users or my token with their email addresses.

 

 

February 09, 2013 10:02
User photo
Bas
coosto

Is there any news when it is possible to submit a comment on behalf of another user?

February 20, 2013 12:01
User photo
Clinton Cory
korcett

Does submitter_id not work? You should be able to specify the submitter_id of the ticket creation request. For new users, you'd need to create the user, determine their id, and then create the ticket with the submitter_id of that user assigned.

For reference, 

Some base sample code for creating tickets can be found here:
http://pastebin.com/u/Mushroomheadbangers

Might be easier to work with.

August 20, 2013 11:05