Get HTML response instead JSON using API
-
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:
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! -
@davide1611 Which version of FOG do you use?
-
I’m running the latest stable version: 1.5.8
-
Solved! Remember to check the checkbox: API enabled
-
@davide1611 Well done. Great you got it fixed yourself! I restorted you topic as I think it might be helpful to others as well!!