Netgate Discussion Forum
    • Categories
    • Recent
    • Tags
    • Popular
    • Users
    • Search
    • Register
    • Login

    pf-sense-api-client

    Scheduled Pinned Locked Moved Multi-Instance Management
    9 Posts 3 Posters 486 Views 4 Watching
    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.
    • P Offline
      philippe richard
      last edited by

      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.

      M 1 Reply Last reply Reply Quote 0
      • M Offline
        marcosm Netgate @philippe richard
        last edited by

        Yes if it's the offcial API / Nexus.
        https://github.com/Netgate/pfsense-api

        P 1 Reply Last reply Reply Quote 0
        • P Offline
          philippe richard @marcosm
          last edited by philippe richard

          @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

          1 Reply Last reply Reply Quote 0
          • M Offline
            marcosm Netgate
            last edited by

            What pfSense version is that on?

            P 1 Reply Last reply Reply Quote 0
            • P Offline
              philippe richard @marcosm
              last edited by

              @marcosm said in pf-sense-api-client:

              What pfSense version is that on?

              25.07.1-RELEASE (amd64)

              1 Reply Last reply Reply Quote 0
              • M Offline
                marcosm Netgate
                last edited by

                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.

                P 2 Replies Last reply Reply Quote 0
                • P Offline
                  philippe richard @marcosm
                  last edited by

                  @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)
                  
                  1 Reply Last reply Reply Quote 0
                  • P Offline
                    philippe richard @marcosm
                    last edited by philippe richard

                    @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"}

                    L 1 Reply Last reply Reply Quote 0
                    • L Offline
                      ldangpfng @philippe richard
                      last edited by

                      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.

                      1 Reply Last reply Reply Quote 0
                      • First post
                        Last post
                      Copyright 2025 Rubicon Communications LLC (Netgate). All rights reserved.