Creating a request on behalf of unverified end user | Community
Skip to main content

Creating a request on behalf of unverified end user

  • October 14, 2022
  • 4 replies
  • 0 views

Deyan

Hello I have created a demo free trial zendesk account and with it, by following this article https://developer.zendesk.com/documentation/ticketing/using-the-zendesk-api/making-api-requests-on-behalf-of-end-users/, I am trying to create a request for users that have not used (not verified emails) my instance of zendesk. If I understand the article this should be possible, I have created an Auth Client and I am creating successfully impersonated scoped token, but when trying to create the request it self, I am getting a bad request 400 with error: 

This API version does not support the X-On-Behalf-Of header. Please use an API token.

My guess is that this is most likely duo to the free trial account but still it would be nice if someone can verify this for me, thank you.

4 replies

Greg29
  • October 17, 2022

Hi Deyon! In that article, we discuss using an OAuth token to make these requests, however the requests that you are making are using an API token instead. I would recommend checking your script to ensure that it's calling the correct auth function when making this request, as opposed to the auth function that may be fetching the OAuth token or other requests in your script.


Deyan
  • Author
  • October 17, 2022

Hello Greg, yes I was using the API token today and last week but I was also using the OAuth token, I did made a request with it right now also got this on post to api/v2/requests:
these are the headers used:

Authorization: `Authorization: Bearer ${token}`,
'X-On-Behalf-Of': 'deyan2218@gmail.com',

Greg29
  • October 17, 2022
I just realized what the issue was...you're using the Requests endpoint, which is only for end-users/anonymous users. If you want to send requests on behalf of your end users, you don't need to pass in any authentication, you just need to use their email address in the request. Here's an example:
 
curl https://subdomain.zendesk.com/api/v2/requests.json \
-d '{"request": {"requester": {"email": "email@example.net", "name": "Anonymous customer"}, "subject": "Help!", "comment": {"body": "My printer is on fire!" }}}' \
-X POST -H "Content-Type: application/json"

Deyan
  • Author
  • October 18, 2022

Yes but this is for anonymous users, I saw that there is a rate limit for those requests that are 5 per hour (that is way too low for our needs), if there was no rate limit or if it was higher that would have been ok.

According to the article requests with impersonated token should be possible for agent to create a request or a ticket for an end-user who isn't verified yet if I understand this correctly

When I try to make a request like to api/v2/requests I get the above error: This API version does not support the X-On-Behalf-Of header. Please use an API token.

And when I try to api/v2/tickets I get 401 error: "Couldn't authenticate you"

Here is the token that I am using and the header