Ad Widget

Collapse

Can't get API to work

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • khaaaaaaan
    Junior Member
    • Nov 2021
    • 2

    #1

    Can't get API to work

    I inherited a zabbix installation and want to collect some information using the API. however all I'm getting is 401s. for instance:

    Code:
    curl --request POST \
    --url https://server.com/api_jsonrpc.php \
    --header 'Accept: application/json' \
    --header 'Content-Type: application/json' \
    --data '{
    "jsonrpc": "2.0",
    "method": "apiinfo.version",
    "id": 1,
    "auth": null,
    "params": {}
    }'
    <!DOCTYPE HTML PUBLIC "-//IETF//DTD HTML 2.0//EN">
    <html><head>
    <title>401 Unauthorized</title>
    </head><body>
    <h1>Unauthorized</h1>
    <p>This server could not verify that you
    are authorized to access the document
    requested. Either you supplied the wrong
    credentials (e.g., bad password), or your
    browser doesn't understand how to supply
    the credentials required.</p>
    <hr>
    <address>Apache/2.4.38 (Debian) Server at server.com Port 443</address>
    </body></html>
    this obviously shouldn't happen, because this request shouldn't even need authentication.
    following https://www.zabbix.com/documentation...rming_requests I also tried "user.login" without any success.

    I'm wondering if the API needs to be activated first somehow... any ideas what might be going wrong, here?
  • tim.mooney
    Senior Member
    • Dec 2012
    • 1427

    #2
    Does it make a difference if you use "https://server.com/zabbix/api_jsonrpc.php" as the URL, instead of the one you're using?

    Have you looked at your PHP FPM logs and/or the Apache httpd logs, to see what it's logging for one of these failed requests?

    Comment

    • khaaaaaaan
      Junior Member
      • Nov 2021
      • 2

      #3
      I'm an idiot. I should have checked the web server config first. -- turns out it requires basic auth.

      Comment

      Working...