API System giving 404 errors
- FOG Version: 1.4.4
- Ubuntu 16.04
- PHP 7.1
- Service Version:
I have decided to attempt to learn the API system, with the overall goal in mind to use the API system to create a script that creates and rename images based on our hosts. I enabled the API System in the FOG Configure settings and tried experimenting with the API by running: “curl -H ‘fog-api-token: token’ -H ‘fog-user-token: token’ -X GET http://fogserver/fog/task/current” to list our current/active task. However, I keep getting 404 errors returned as shown in the following image.
If anyone could help me understand why I keep getting these errors and/or help me better understand the API it would be much appreciated.
So the problem you’re seeing is due to how Ubuntu deals with named virtual hosts. I’m going on a limb and guessing you’re accessing the fog server via dnsname of the fog server? What if you change the dnsname to ip? The fog config for Apache doesn’t add in named hosts by dns name, by default. It does it based on the ip. Because the servername element of the config is the ip, that config isn’t running for the dns called name. The default site is the trying to route it, which is not configured to rewrite the request to the API.
Because the commands that I know work don’t work for you, something else must be wrong here. I think Tom is on the right path.
Do me a favor and try:
sudo a2dissite 000-default sudo systemctl restart apache2
@Wayne-Workman this endpoint does not work either. I tried every single endpoint in the example you showed and none of them seem to return anything but a 404, whether I’m using CURL, Postman, or a Node.js application.
@mwarner You’re trying
/fog/task/currentbut I think it’s supposed to be
Look at these posts for examples:
Any thoughts on why this is 404ing?
@Tom-Elliott Yes, it is enabled for both user and overall
@george1421 Yes, it is enabled in the configure settings
I’m not seeing a problem. Is API actually enabled for the user and overall?
Is the API system enabled in the FOG Configuration Settings?