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

API - Create Host "error": "Required database field is empty"

Scheduled Pinned Locked Moved Solved
FOG Problems
2
4
845
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.
  • S
    scottybullet
    last edited by Wayne Workman Dec 7, 2017, 8:00 AM Dec 7, 2017, 1:15 PM

    Hello, I am trying to do a create host api call to eventually automate imaging some hardware. I can get data from fog all day long but when it comes to posting data to create a host it gives me this error: “error”: “Required database field is empty” this is what my post looks like:

     $CreateHostJson = @{
                                "name"=  "$vmname"
                                "description"=  "$Description"
                                "primac" =  "$MacAddress"
                                "imagename" =  "$ImageName"    
                                }
            $createHostURL = $baseUri +"/host/create/"
            $createHostResult = Invoke-RestMethod -Uri $createHostURL -Method POST -Headers $headers -body $CreateHostJson -ContentType "application/json"
    

    Any help would be appreciated

    1 Reply Last reply Reply Quote 0
    • T
      Tom Elliott
      last edited by Dec 7, 2017, 2:32 PM

      Change primac to macs: [“$MacAddress”]

      Please help us build the FOG community with everyone involved. It's not just about coding - way more we need people to test things, update documentation and most importantly work on uniting the community of people enjoying and working on FOG! Get in contact with me (chat bubble in the top right corner) if you want to join in.

      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
      • S
        scottybullet
        last edited by Dec 7, 2017, 3:10 PM

        Thanks, Is there any reason the Image name wouldn’t get populated? This works minus the image name:
        $HostJson = @{
        “name”= $vmname
        “description”= $Description
        “macs” = @($MacAddress)
        “imagename” = $ImageName
        }
        $CreateHostJson = ConvertTo-Json($HostJson)
        $createHostURL = $baseUri +“/host/create”
        $createHostResult = Invoke-RestMethod -Uri $createHostURL -Method POST -body $CreateHostJson -Headers $headers -ContentType “application/json”

        1 Reply Last reply Reply Quote 0
        • S
          scottybullet
          last edited by Dec 7, 2017, 3:22 PM

          Got it, this is the syntax from Powershell

          $HostJson = @{
          “name”= $vmname
          “description”= $Description
          “macs” = @($MacAddress)
          “imageID”= $Image.id
          “imagename” = $ImageName
          }
          $CreateHostJson = ConvertTo-Json($HostJson)
          $createHostURL = $baseUri +“/host/create”
          $createHostResult = Invoke-RestMethod -Uri $createHostURL -Method POST -body $CreateHostJson -Headers $headers -ContentType “application/json”

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

          170

          Online

          12.0k

          Users

          17.3k

          Topics

          155.2k

          Posts
          Copyright © 2012-2024 FOG Project