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

Unable to create host through API

Scheduled Pinned Locked Moved Unsolved
FOG Problems
2
2
281
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.
  • C
    cornycopia
    last edited by Dec 7, 2023, 7:17 PM

    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

    J 1 Reply Last reply Dec 8, 2023, 5:13 PM Reply Quote 1
    • J
      JJ Fullmer Testers @cornycopia
      last edited by Dec 8, 2023, 5:13 PM

      @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"
        ]
      } 
      

      Have you tried the FogApi powershell module? It's pretty cool IMHO
      https://github.com/darksidemilk/FogApi
      https://fogapi.readthedocs.io/en/latest/
      https://www.powershellgallery.com/packages/FogApi
      https://forums.fogproject.org/topic/12026/powershell-api-module

      1 Reply Last reply Reply Quote 0
      • 1 / 1
      1 / 1
      • First post
        1/2
        Last post

      181

      Online

      12.0k

      Users

      17.3k

      Topics

      155.2k

      Posts
      Copyright © 2012-2024 FOG Project