Menu

Show posts

This section allows you to view all posts made by this member. Note that you can only see posts made in areas you currently have access to.

Show posts Menu

Messages - jkwan

#1
Hi,
Thank you for your reply.
I managed to use the APIs except the method for searches

Here is a working CURL example for the addClient method :

curl \
--location --request POST 'https://{{fwhost}}/api/wireguard/client/addClient' \
--header 'Authorization: Basic {{token}} \
--header 'Content-Type: application/json' \
--data-raw '{"client":{"tunneladdress":"$address","name":"$user","enabled":1,"pubkey":"$key"}}'


Note that you have to put the client data structure inside a client property.
it's simply a JSON representation of the XML structure described in the documentation :
https://github.com/opnsense/plugins/blob/master/net/wireguard/src/opnsense/mvc/app/models/OPNsense/Wireguard/Client.xml

Same thing for the setClient method, you have just to change the endpoint URL for something like this :
https://{{fwhost}}/api/wireguard/client/setClient/{{uuid}}

For the delete method, it seems that empty data have to be posted like this ;
curl \
--location --request POST 'https://{{fwhost}}/api/wireguard/client/delClient/{{uuid}}' \
--header 'Authorization: Basic {{token}}' \
--data-raw ''


In my curl examples, {{token}} is base64 encoded of $key:$secret, but you can use -u $key:$secret

Regards,
#2
Hi,

I am struggling with the wireguard API.
https://docs.opnsense.org/development/api/plugins/wireguard.html

Is there an example of how to use the search, set and get endpoints for the client service please ?
I do not understand how to pass the parameter of the search query and the data for add and search endpoint.
An example with curl command will really help me.

edit: I found the way to use all APIs except for search methods

Thanks !