Setting up DHCP service with HTTPS API

curl -k -X POST -F data=’{“op”: “set”, “path”: [“service”, “dhcp-server”, “shared-network-name”, “eth1”, “authoritative”]}’ -F key=MY-HTTP-API-PLAINTEXT-KEY https://172.10.1.111/configure

{“success”: false, “error”: “[ service dhcp-server ]\nVyOS had an issue completing a command.\n\nWe are sorry that you encountered a problem while using VyOS.\nThere are a few things you can do to help us (and yourself):\n- Make sure you are running the latest version of the code available at\n https://downloads.vyos.io/rolling/current/amd64/vyos-rolling-latest.iso\n- Consult the forum to see how to handle this issue\n https://forum.vyos.io\n- Join our community on slack where our users exchange help and advice\n https://vyos.slack.com\n\nWhen reporting problems, please include as much information as possible:\n- do not obfuscate any data (feel free to contact us privately if your \n business policy requires it)\n- and include all the information presented below\n\nReport Time: 2021-01-14 13:59:43\nImage Version: VyOS 1.3-rolling-202101020432\nRelease Train: equuleus\n\nBuilt by: j.randomhacker@vyos.io\nBuilt on: Sat 02 Jan 2021 04:32 UTC\nBuild UUID: c0074226-8e70-4a59-bc56-8459b9d56fa0\nBuild Commit ID: ba6dab895279f6\n\nArchitecture: x86_64\nBoot via: installed image\nSystem type: VMware guest\n\nHardware vendor: VMware, Inc.\nHardware model: VMware Virtual Platform\nHardware S/N: VMware-56 4d 8e e3 28 13 01 53-73 10 3a 50 83 4c e3 19\nHardware UUID: e38e4d56-1328-5301-7310-3a50834ce319\n\nTraceback (most recent call last):\n File “/usr/libexec/vyos/conf_mode/dhcp_server.py”, line 291, in \n c = get_config()\n File “/usr/libexec/vyos/conf_mode/dhcp_server.py”, line 114, in get_config\n for subnet, subnet_config in (dict_search(‘subnet’, network_config).items() or {}):\nAttributeError: ‘NoneType’ object has no attribute ‘items’\n\n\n\n[[service dhcp-server]] failed\nCommit failed\n”, “data”: null}

Hello @ergao, which VyOS version running? I have played with HTTPS API for DHCP on the latest rolling, and it looks works as expected.

One note: DHCP required more commands, bit more examples you can find in VyOS blog

To compensate for the statelessness, you can send multiple commands at once:

[{"op": "set;", "path": ["system", "host-name"], "value": "vyos-router"},
 {"op": "comment;", "path": ["system", "host-name"], "value": "Modified by the API"},
 {"op": "delete;", "path": ["system", "options", "reboot-on-panic"]}]
1 Like

Thank you very much for your reply. I’ll go to the blog to find the relevant information。
I use “value” to report the same mistake
curl -k -X POST -F data=’{“op”: “set”, “path”: [“service”, “dhcp-server”, “shared-network-name”, “eth1”], “value”: “authoritative”}’ -F key=MY-HTTP-API-PLAINTEXT-KEY https://172.10.1.111/configure