Create a Post
cancel
Showing results for 
Search instead for 
Did you mean: 
mateus_cruz
Explorer
Jump to solution

Adding new network groups via API gives out a Error 404

Hello everyone,

I'm having trouble adding new network groups using the API add-group endpoint. I was able can create new hosts using the add-host endpoint so that confirms that my user does have Write permissions too so the issue is not related to that. I followed the documentation part which states the API has a option for "add-group with multiple members" but can't seem to make it work, I end up getting 404 client errors for some reason. When I try the format for adding a group with a single member I also keep getting 404 errors. Is there something I don't know about? Maybe this option is deprecated or something?

Here's an example just like the payload I'm trying to POST to the API add-group endpoint...

{

      "name" :  "my_testing_group",

      "members" :  [ "192.168.1.156", "192.168.1.158" ]

}

0 Kudos
1 Solution

Accepted Solutions
Amir_Senn
Employee
Employee

Hi,

I see that in the member you used IPs and not hostname.

I reproduced in my env. I tried to add IPs to a group and got a failure, after creating hosts for IPs I managed to add them with hostname. Can you try to create an object for them as well and then retry?

Kind regards, Amir Senn

View solution in original post

0 Kudos
7 Replies
Amir_Senn
Employee
Employee

Hi,

I see that in the member you used IPs and not hostname.

I reproduced in my env. I tried to add IPs to a group and got a failure, after creating hosts for IPs I managed to add them with hostname. Can you try to create an object for them as well and then retry?

Kind regards, Amir Senn
0 Kudos
mateus_cruz
Explorer

Hey,

the provided solution worked, but only when I added the hosts using the API mgmt_cli command line, when adding using the Web Services API (which I used via Python) it seems like the hosts objects are not saved and don't show up anywhere, even after publishing. Weird thing is that I can make multiple add-host commands in the web services API and it doesn't complain about repeated hosts being added, however, using the mgmt_cli and adding the same host more than once displays a error message since the host already exists of course.

0 Kudos
Amir_Senn
Employee
Employee

Any case the publish is to another session? When you run a few commands do you save/provide session ID?

Kind regards, Amir Senn
0 Kudos
mateus_cruz
Explorer

Hey Amir,

I found the problem, my python code ended my user session too soon, not giving time for checkpoint to publish the session properly, I fixed that. Your help with the insight of using hostnames instead of IPs solved my main problem. Thank you for the help Amir!

0 Kudos
johnnyringo
Advisor

Would be great if you could share the Python code snippet.  I'm currently working with the web services API and am curious what everyone's using as far as modules/libraries and especially how they're handling sessions and timeouts. 

Personally, I'm using aiohttp so I can make the calls async, but would image requests is the most popular.  

0 Kudos
mateus_cruz
Explorer

Hey I'm not sure I can share my code, but I can tell you I'm using the requests library, first using the /login endpoint, then using the returned token from the POST request to make further queries in the API.

0 Kudos
Amir_Senn
Employee
Employee

You're welcome

Kind regards, Amir Senn
0 Kudos

Leaderboard

Epsum factorial non deposit quid pro quo hic escorol.

Upcoming Events

    CheckMates Events