Can anyone point me to the endpoints for getting, adding, and deleting MAC address to the CP white list via the API?
Thanks
API docs: https://docs.opnsense.org/development/api/core/captiveportal.html
Thank you. I am aware of that documentation, but it is rather sparse.
The only endpoint that makes sense to me for this purpose would be api/captiveportal/settings/setzone/ (I have acquired the uuid with searchzones).
I know that I should be including a JSON object in the body of the request, but there's nothing to indicate what it should contain. I've tried what seemed meaningful values for this and other endpoints, but the only response I ever receive is {"result":"failed"}
Is there more comprehensive documentation for the API, or somewhere that would give me an idea of what my JSON object should contain?
Thanks
usually not, but you can look either on the model XML (https://github.com/opnsense/core/blob/master/src/opnsense/mvc/app/models/OPNsense/CaptivePortal/CaptivePortal.xml#L9) or download it first with the get call.
Thanks. I don't know why I didn't think to examine the result of a get first. Exploring it now.
b.
Thank you for helping out the newb.
When I get https://10.15.1.227/api/captiveportal/settings/getzone/2dd820e7-0995-4174-8546-6fa66fb0bf5f
I get a big json object. If I post it right back to /setzone, no alteration, I get the error:
{"errorMessage":"Error at /usr/local/opnsense/mvc/app/models/OPNsense/Base/FieldTypes/BaseField.php:700 - strtolower() expects parameter 1 to be string, array given (errno=2)","errorTitle":"An API exception occured"}
I can pick out certain things and change successfully, like enable / disable, or description.
The relevant portion I would like to post is
{"zone":{"allowedMACAddresses":{"00:11:22:33:44:55":{"value":"00:11:22:33:44:55","selected":1},"aa:bb:cc:dd:ee:ff":{"value":"aa:bb:cc:dd:ee:ff","selected":1}}}}
but this generates the same error.
I can send
{"zone":{"allowedMACAddresses":"aa:bb:cc:dd:ee:ff"}}
Which works, but, expectedly, this replaces any MAC addresses on the list.
Thanks
try to post such multi value and dropdown fields as CSV string.
Thank you so much!
That did it.