Getting 401 'Unauthorized' error when using CURL, works OK when pasted in browser



投稿日時:2022年11月03日

When I paste the following URL in the address bar of browser: it works fine:

https://my-domain.zendesk.com/api/v2/users.json

However, when I attempt to use the following cURL call

curl https://my-domain.zendesk.com/api/v2/users.json -v -u my@email.com:my#password, 

I get an error:

*   Trying 104.16.51.111:443...
* Connected to my-domain.zendesk.com (104.16.51.111) port 443 (#0)
* schannel: disabled automatic use of client certificate
* ALPN: offers http/1.1
* ALPN: server accepted http/1.1
* Server auth using Basic with user 'my@email.com'
> GET /api/v2/users.json HTTP/1.1
> Host: my-domain.zendesk.com
> Authorization: Basic ***
> User-Agent: curl/7.83.1
> Accept: */*
>
* Mark bundle as not supporting multiuse
< HTTP/1.1 401 Unauthorized
< Date: Wed, 02 Nov 2022 19:24:38 GMT
< Content-Type: application/json; charset=utf-8
< Content-Length: 37
< Connection: keep-alive
* Authentication problem. Ignoring this.
< www-authenticate: Basic realm="Web Password"
< strict-transport-security: max-age=31536000;
< cache-control: no-cache
< x-zendesk-origin-server: classic-app-server-85767c77db-qrbvk
< set-cookie: _zendesk_cookie=***--***; path=/; expires=Thu, 02 Nov 2023 13:01:33 GMT; secure; HttpOnly; SameSite=None
< x-request-id: 763f4064c87917bd-EWR
< X-Request-ID: 763f4064c87917bd-EWR
< x-runtime: 0.058717
< X-Zendesk-Zorg: yes
< CF-Cache-Status: DYNAMIC
< Report-To: {"endpoints":[{"url":"https:\/\/a.nel.cloudflare.com\/report\/v3?s=***"}],"group":"cf-nel","max_age":604800}
< NEL: {"success_fraction":0.01,"report_to":"cf-nel","max_age":604800}
< Set-Cookie: __cfruid=***; path=/; domain=.my-domain.zendesk.com; HttpOnly; Secure; SameSite=None
< Server: cloudflare
< CF-RAY: 763f4064c87917bd-EWR
<
{"error":"Couldn't authenticate you"}* Connection #0 to host my-domain.zendesk.com left intact

What could be the problem? My password contains special characters. I tried escaping them (ex. %23 for '#'), didn't work.

I have reviewed the documentation. I cannot find a "Troubleshooting" section specific to API.

I have an "Essentials"-level subscription. Does Zendesk have to activate something about my account so I can retrieve End Users?


0

8

8件のコメント

サインインしてコメントを残してください。

お探しのものが見つかりませんか?

新規投稿