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

API PUT request not working

Scheduled Pinned Locked Moved
FOG Problems
api api help fogapi-psmodule
3
5
731
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.
  • B
    brian.mainake
    last edited by JJ Fullmer Mar 31, 2023, 6:50 AM Oct 21, 2022, 8:37 PM

    Hey guys,

    For automation purposes, I’m trying to update host via the API with PUT request. I’ve read the API doc and was able to do a GET request and receive the JSON formatted response.

    The issue is when I try to do a PUT request to update the “primac” value and I’m using Postman to send these request at the moment. When I send the request, it returns status “200” and the JSON data of the host but it doesn’t actually update the “primac” value based on the JSON body i provided.

    The link is http://<fog ip>/fog/host/hostID/update
    I included the 2 tokens in the headers.

    JSON body looks like this:

    {
    “primac”: “01:02:03:04:05”
    }

    also tried this:

    {
    host: {
    “primac”: “01:02:03:04:05”
    }
    }

    but also not luck. Please let me know if I’m missing anything or if there’s any alternatives.

    The other thing is I’m thinking of just write my own API and make changes directly to the SQL server but trying to avoid that.

    Thanks in advanced!

    J 1 Reply Last reply Oct 21, 2022, 10:10 PM Reply Quote 0
    • J
      JJ Fullmer Testers @brian.mainake
      last edited by Oct 21, 2022, 10:10 PM

      @brian-mainake Have you tried the powershell module for the api?

      It looks like you’re trying to add a primary mac, I have this function https://fogapi.readthedocs.io/en/latest/commands/Add-FogHostMac/ that can do that.
      You can look at the code at this link https://github.com/darksidemilk/FogApi/blob/master/FogApi/Public/Add-FogHostMac.ps1 and it will give you an idea of how I’m getting that working. As with any api they syntax can be tricky at times but it’s pretty intuitive once you get a couple calls working.

      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

      B 1 Reply Last reply Oct 21, 2022, 11:32 PM Reply Quote 0
      • B
        brian.mainake @JJ Fullmer
        last edited by Oct 21, 2022, 11:32 PM

        @jj-fullmer Thanks for that. I actually got it to work 🙂

        I was using the wrong object.

        http://<IP>/fog/host/objectID/edit
        

        Instead it suppose to be

        http://<IP>/fog/macaddressassociation/objectID/edit
        

        It works like a charm now.

        Thanks for the help though!

        J 1 Reply Last reply Nov 28, 2022, 12:26 PM Reply Quote 0
        • J
          judzk @brian.mainake
          last edited by judzk Nov 28, 2022, 6:54 AM Nov 28, 2022, 12:26 PM

          @brian-mainake Hi, same problem here, but when a use

          http://<IP>/fog/macaddressassociationS/objectID/edit
          

          I got

          Response status code does not indicate success: 501 (Not Implemented).
          

          Did you use JJ module or did you manage to do it by yourself?

          Edit : Found why I lost 1h30. macaddressassociationS instead of macaddressassociation …

          B 1 Reply Last reply Nov 29, 2022, 3:37 PM Reply Quote 0
          • B
            brian.mainake @judzk
            last edited by Nov 29, 2022, 3:37 PM

            @judzk sorry I just saw this and yes I also see the error.

            Glad its working for you now.

            I also didn’t use the powershell module.

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

            147

            Online

            12.0k

            Users

            17.3k

            Topics

            155.2k

            Posts
            Copyright © 2012-2024 FOG Project