Unable to create host through API
-
Hi,
I’m trying to add a host to my server through the API, but I get a 500 response back.
I’m using Thunder Client (postman for vscode) to send the requests with all the tokens and content header present. I can successfully issue GET and PUT commands, but only get a 500 status back for POST requests.Endpoint target: http://myfogserver.com/fog/host/
JSON Body:
{
“name”: “APITest”,
“macs”: “A4:BF:01:6E:E4:F2”
}My objective is to add a basic host to my fog server. Is there an arguement I’m missing which is required?
Any help would be appreciated.
I’m on FOG version 1.5.10
-
@cornycopia Hi!
Are you familiar with powershell at all? If not, it’s too hard to learn,
I have made a powershell module to help with managing these things (see my signature for more links)For example there’s a command to make a new fog host https://fogapi.readthedocs.io/en/latest/commands/New-FogHost/
I would recommend giving that a go.That said, let’s take a look at why this isn’t working
The first issue I see with your body is the macs need to be an array
You might also have to have the modules param defined in the body.
In my PowerShell function I have a function to get all the modules and I filter it to the default ones so that the behavior is the same as when you add a host in the gui instead of creating a host with nothing in it.
https://fogapi.readthedocs.io/en/latest/commands/Get-FogModules/Here’s a simplified table of that output, I think the ids are always the same in all installs, but they could be unique to your install
id name -- ---- 1 Directory Cleaner 2 User Cleanup 3 Display Manager 4 Auto Log Out 5 Green FOG 6 Snapins 7 Client Updater 8 Host Registration 9 Hostname Changer 10 Printer Manager 11 Task Reboot 12 User Tracker 13 Power Management
Anyway, here’s an example of a json body for creating a host with the default service modules enabled (these are my defaults, you may have different ones configured)
{ "macs": [ "A4:BF:01:6E:E4:F2" ], "name": "demo", "modules": [ "7", "9", "13", "6", "11", "2", "12" ] }