Ad Widget

Collapse

404 Not Found when calling the Zabbix API

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • WillG
    Junior Member
    • May 2021
    • 5

    #1

    404 Not Found when calling the Zabbix API

    I am trying to connect to the Zabbix API on Ubuntu with a Nginx web server installed. The Zabbix server GUI works fine and I have not problems getting info from Zabbix agents. However when I make the following call to the Zabbix API

    curl -H "Content-Type: application/json.rpc" -X POST http://127.0.0.1/api_jsonrpc.php -d'
    {
    "jsonrpc": "2.0",
    "method": "user.login",
    "params": {
    "user": "Admin",
    "password": "zabbix"},
    "id": 1
    }'

    Here is the response I receive:
    <html>
    <head><title>404 Not Found</title></head>
    <body>
    <center><h1>404 Not Found</h1></center>
    <hr><center>nginx/1.18.0 (Ubuntu)</center>
    </body>
    </html>

    The Zabbix server is version 5.0.9
    Ubuntu version: 20.04.2
    Nginx version: 1.18.0

    The latest nginx error.log file is empty.

    I want to be able to make API calls to retrieve data from the Zabbix server to store locally.

    Thanks in advance for any help to make this work
    Wil

  • WillG
    Junior Member
    • May 2021
    • 5

    #2
    It doesn't matter, I get the same result either way. Yes you have the recommended endpoint, I had omitted the "zabbix" part or the url in an attempt to connect.

    Comment

    • Atsushi
      Senior Member
      • Aug 2013
      • 2028

      #3
      Are you specifying the same host name or IP address as when accessing the web frontend?
      If the URL to access is different, it is possible that another directory will be accessed and a 404 error will occur depending on the settings such as the virtual host.

      Comment

      • WillG
        Junior Member
        • May 2021
        • 5

        #4
        I have tried localhost, 127.0.0.1 as well as using the static IP from both the server and the agent. All attempts have resulted in the same response.

        Comment

        • WillG
          Junior Member
          • May 2021
          • 5

          #5
          So I have discovered that the following API call works from the terminal on localhost. When I submit this call I receive a json response with an authentication token as expected. Note that I have removed the '/zabbix/' part of the URL path and have changed the Content-Type to application/json.

          Code:
          curl -H "Content-Type: application/json" -X POST http://localhost/api_jsonrpc.php -d'
          {
          "jsonrpc": "2.0",
          "method": "user.login",
          "params": {
          "user": "Admin",
          "password": "zabbix"},
          "id": 1
          }'
          The API calls are still answered by 404 from any other machine on the network.

          Comment

          • Atsushi
            Senior Member
            • Aug 2013
            • 2028

            #6
            Are you sure that you can access Zabbix's Web front end using a web browser with the URL "http://localhost/"?

            Comment

            • WillG
              Junior Member
              • May 2021
              • 5

              #7
              Yes, that's only way of accessing the Zabbix front end. So this issue is resolved as the only need for us is to access Zabbix from the zabbix server itself. Thanks.

              Comment

              • cyber
                Senior Member
                Zabbix Certified SpecialistZabbix Certified Professional
                • Dec 2006
                • 4811

                #8
                Sure its

                and not

                ?

                Comment

                Working...