• Recent
  • Unsolved
  • Tags
  • Popular
  • Users
  • Groups
  • Search
  • Register
  • Login
  • Recent
  • Unsolved
  • Tags
  • Popular
  • Users
  • Groups
  • Search
  • Register
  • Login

Get HTML response instead JSON using API

Scheduled Pinned Locked Moved
Tutorials
2
5
651
Loading More Posts
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • D
    davide1611
    last edited by davide1611 Apr 21, 2020, 3:44 AM Apr 21, 2020, 9:44 AM

    Hi everyone,
    I’m implementing a script to query my FOG server looking the documentation at https://news.fogproject.org/simplified-api-documentation/

    When I make a GET request:

    curl -H 'fog-api-token: my_api_token' -H 'fog-user-token: my_fog_user' -X GET http://192.168.1.1/fog/task/current -o list.json
    
    

    List.json remain empty and on console get:
    2a8d834d-f0fa-4210-b6ab-7a0959bb48cb-image.png

    Using postman I found out that the result is an HTML file.

    Using python

    import requests
    
    usertoken='my_user_token'
    apitoken='my_api_token'
    headers = {'fog-user-token': usertoken, 'fog-api-token':apitoken }
    r = requests.get('http://192.168.1.1/fog/task/current', params=headers)
    print(r.url)
    

    The script print

    http://192.168.1.1/fog/management/index.php
    

    Need I to modify something on FOG server configuration? I would like to get my current task via JSON file.
    Thanks!

    1 Reply Last reply Reply Quote 0
    • S
      Sebastian Roth Moderator
      last edited by Apr 21, 2020, 10:33 AM

      @davide1611 Which version of FOG do you use?

      Web GUI issue? Please check apache error (debian/ubuntu: /var/log/apache2/error.log, centos/fedora/rhel: /var/log/httpd/error_log) and php-fpm log (/var/log/php*-fpm.log)

      Please support FOG if you like it: https://wiki.fogproject.org/wiki/index.php/Support_FOG

      1 Reply Last reply Reply Quote 0
      • D
        davide1611
        last edited by Apr 21, 2020, 11:45 AM

        I’m running the latest stable version: 1.5.8

        1 Reply Last reply Reply Quote 0
        • D
          davide1611
          last edited by Apr 21, 2020, 11:57 AM

          Solved! Remember to check the checkbox: API enabled

          1 Reply Last reply Reply Quote 0
          • S
            Sebastian Roth Moderator
            last edited by Apr 21, 2020, 3:05 PM

            @davide1611 Well done. Great you got it fixed yourself! I restorted you topic as I think it might be helpful to others as well!!

            Web GUI issue? Please check apache error (debian/ubuntu: /var/log/apache2/error.log, centos/fedora/rhel: /var/log/httpd/error_log) and php-fpm log (/var/log/php*-fpm.log)

            Please support FOG if you like it: https://wiki.fogproject.org/wiki/index.php/Support_FOG

            1 Reply Last reply Reply Quote 0
            • 1 / 1
            1 / 1
            • First post
              3/5
              Last post

            167

            Online

            12.0k

            Users

            17.3k

            Topics

            155.2k

            Posts
            Copyright © 2012-2024 FOG Project