401 unauthorised for POST /api/v2/requests
I'm running a static site seperate to my zendesk account in which we are trying to create anonymous tickets.
I'm using a Cloudflare worker to send these requests and per the docs, I'm calling the https://<mydomain>.zendesk.com/api/v2/requests url which shouldn't need any authentication from my understanding according to these docs:
https://developer.zendesk.com/api-reference/ticketing/tickets/ticket-requests/
I'm also sending the Bearer token header from a generated API token (confirmed correct).
I keep encountering a 401 Unauthorized error when sending a payload, even the payload specified in the docs:
{"request": {"requester": {"name": "Anonymous customer"}, "subject": "Help!", "comment": {"body": "My printer is on fire!" }}}
If I send NO payload, I get a 200 OK status, which suggests the data is maybe malformed but I've tried various versions of this.
I thought it may be a CORS issue but I've set it to both the domain I'm sending to and to allow all ("*") for testing and still can't create an anonymous ticket from a different domain.
Any help would be appreciated.
-
Hi James Macpherson,
There are 2 factors to consider here: authenticated and unauthenticated requests:
It is true that anonymous requests are allowed and do not need any authentication. However, this needs to be configured in the Admin center > People > Configuration > End users > Anybody can submit a ticket as seen below:
As for authenticated requests, you mentioned you used a bearer token generated from API token. Not sure what you meant here but need to use basic authentication for API tokens. Only scoped OAuth tokens can be used as a bearer token. More details here.
I hope that helps.
-
Hi Ahmed,
My settings are Enabled for 'Anybody can submit tickets'
Thanks for that, I tried the Basic authentication and base64 encoded the following structure:
jdoe@example.com/token:[REDACTED BY ZENDESK]
and have also tried without token (just {email}/{password} encoded)
I'm sending a payload such as:
{
"request": {
"requester": {"name": "Anonymous customer", "email": "james@test.com"},
"subject": "Help!",
"comment": {"body": "My printer is on fire!" }
}
}And now receive a 422 Unprocessable Entity.
-
Hi James! I see that you had a ticket open for this issue and from what I can tell, everything appears to be resolved now. If that's not correct, let me know what you're stuck on!
サインインしてコメントを残してください。
3 コメント