API PUT request not working
-
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!
-
@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. -
@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!
-
@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 …
-
@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.