Create Group with Resource via API but Resource does not appear. #1703

Open
opened 2025-11-20 06:05:04 -05:00 by saavagebueno · 2 comments
Owner

Originally created by @YapWC on GitHub (Mar 13, 2025).

Originally assigned to: @pascal-fischer on GitHub.

I am testing out Netbird API and created a Group with the following python code excluded the peer.

import requests
import json

url = "https://<my_network>/api/groups"
payload = json.dumps({
  "name": "devs",
  "resources": [
    {
      "id": "chacdk86lnnboviihd7g",
      "type": "host"
    }
  ]
})
headers = {   
  'Content-Type': 'application/json',  
  'Accept': 'application/json',
  'Authorization': 'Token <my_token>'
}

response = requests.request("POST", url, headers=headers, data=payload)

print(response.text)

It was successfully created with this being returned.
{"id":"cv9cidkig2os73e68gng","issued":"api","name":"devs","peers":null,"peers_count":0,"resources":[{"id":"chacdk86lnnboviihd7g","type":"host"}],"resources_count":1}

But when I went to the Netbird Dashboard I don't see a network resource even though it shows in devs group that there is 1 Network Resource associated.
Image
Image

I tried to delete the Network Resource via API but got null in return. Now I am not sure how I can delete it.

Originally created by @YapWC on GitHub (Mar 13, 2025). Originally assigned to: @pascal-fischer on GitHub. I am testing out Netbird API and created a Group with the following python code excluded the peer. ``` import requests import json url = "https://<my_network>/api/groups" payload = json.dumps({ "name": "devs", "resources": [ { "id": "chacdk86lnnboviihd7g", "type": "host" } ] }) headers = { 'Content-Type': 'application/json', 'Accept': 'application/json', 'Authorization': 'Token <my_token>' } response = requests.request("POST", url, headers=headers, data=payload) print(response.text) ``` It was successfully created with this being returned. `{"id":"cv9cidkig2os73e68gng","issued":"api","name":"devs","peers":null,"peers_count":0,"resources":[{"id":"chacdk86lnnboviihd7g","type":"host"}],"resources_count":1}` But when I went to the Netbird Dashboard I don't see a network resource even though it shows in devs group that there is 1 Network Resource associated. <img width="1184" alt="Image" src="https://github.com/user-attachments/assets/c84a9fbd-9e7d-4f48-b95a-43c609632a30" /> <img width="1393" alt="Image" src="https://github.com/user-attachments/assets/7ebc4ac7-4990-4d65-ac0a-683beee62e4a" /> I tried to delete the Network Resource via API but got null in return. Now I am not sure how I can delete it.
saavagebueno added the bugmanagement-serviceapi labels 2025-11-20 06:05:04 -05:00
Author
Owner

@pascal-fischer commented on GitHub (Mar 13, 2025):

Hi @YapWC,

did you ever create a resource? I saw you created a group and assigned a resourceID to that group. The groups endpoint does not check if all the peers and resources you define actually exist. So my guess is the script just added a non-existing ID to the group. To delete the group just keep using the API. Send an update request for the group with an empty array of resources. That should clear the group and you will be able to delete it from the dashboard.

I will note for us to update the groups endpoint to actually check the existence of a resource before adding it to the group.

@pascal-fischer commented on GitHub (Mar 13, 2025): Hi @YapWC, did you ever create a resource? I saw you created a group and assigned a resourceID to that group. The groups endpoint does not check if all the peers and resources you define actually exist. So my guess is the script just added a non-existing ID to the group. To delete the group just keep using the API. Send an update request for the group with an empty array of resources. That should clear the group and you will be able to delete it from the dashboard. I will note for us to update the groups endpoint to actually check the existence of a resource before adding it to the group.
Author
Owner

@YapWC commented on GitHub (Mar 17, 2025):

Hi @pascal-fischer yeap your explanation is spot on and I have tried your method to update the group with empty resource and was able to delete the user after that. Thanks for the help and proactiveness, much appreciated!

@YapWC commented on GitHub (Mar 17, 2025): Hi @pascal-fischer yeap your explanation is spot on and I have tried your method to update the group with empty resource and was able to delete the user after that. Thanks for the help and proactiveness, much appreciated!
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: SVI/netbird#1703