pf-sense-api-client
-
Hello everyone,
is this the right place to ask questions about using pf-sense-api-client?
I'm trying to use firewall_update_alias to update an alias and I'm getting an error that I don't understand.
-
Yes if it's the offcial API / Nexus.
https://github.com/Netgate/pfsense-api -
@marcosm
Hello, thank you for your response.I am experiencing a problem with updating an alias by its ID. The authentication part is working correctly: I can list aliases and retrieve their IDs. However, when I try to update an alias using its ID, I get an error code stating that the alias name does not exist.
Here is the code example:
alias_id = "25" # Remplacez par l'identifiant réel nouvel_alias = FWAlias(name="TEST_API",) update_req = FWUpdateAliasreq(alias=nouvel_alias, id=alias_id) result = firewall_update_alias.sync(client=devApi, id=alias_id, body=update_req) print(result)_text
the error message:
Error(errcode=400, errlevel=<pfapi.types.Unset object at 0x7d55248423c0>, errmsg='name missing', alerts=<pfapi.types.Unset object at 0x7d55248423c0>, additional_properties={})and the logs on the pfSense:
2025-09-03 15:17:09.000000-04:00 pfnet-controller 36252 WARNING 54631 [x.x.x.x:38678] POST /api/aliases/25 (DONE 0.513ms) ERROR: name missing
2025-09-03 15:17:09.000000-04:00 pfnet-controller 36252 Updating alias name: , ID: 25...
2025-09-03 15:17:09.000000-04:00 pfnet-controller 36252 > {"alias": {"name": "TEST_API"}, "id": "25"}
2025-09-03 15:17:09.000000-04:00 pfnet-controller 36252 DEBUG 54631 [x.x.x.x:38678] POST /api/aliases/25 -
What pfSense version is that on?
-
-
Are you trying to update it using the index number? If so, try using the name; aliases are now identified by their name rather than the index number.
-
@marcosm
Hello, do you want me to put the alias name in here?firewall_update_alias.sync(client=devApi, id=**TEST_API**, body=update_req)
-
@marcosm said in pf-sense-api-client:
Are you trying to update it using the index number? If so, try using the name; aliases are now identified by their name rather than the index number.
Yes, I was updating it using its ID number. If I change the ID to the name, I still get the same error.
2025-09-04 16:13:23.000000-04:00 pfnet-controller 2646 WARNING 43643 [x.x.x.x:34302] POST /api/aliases/TEST_API (DONE 1.378ms) ERROR: name missing
2025-09-04 16:13:23.000000-04:00 pfnet-controller 2646 Updating alias name: , ID: 25...
2025-09-04 16:13:23.000000-04:00 pfnet-controller 2646 > {"alias": {"name": "TEST_API"}, "id": "TEST_API"} -
The schema definition was out of sync with the handler; it expects the direct alias structure instead of a nested one. Please pull the repo again and test; you'll need a bit of change in the code:
existing_name="a1" update_req = FWUpdateAliasReq(name=existing_name, descr="update-descr") result = firewall_update_alias.sync(client=devApi, id=existing_name, body=update_req) print(result)
A hint on checking if the code in the repository is doing the right thing is to test out what the GUI provides in the request - use the web browser dev-tools Network tab. If what you send doesn't match then we have a glitch in the schema definition that needs resolving.
thanks for testing.