need help with wol api

Started by pear, February 03, 2019, 02:45:52 PM

Previous topic - Next topic
hello

please can someone help me with WOL API?
i am able to wake all already defined computers at once with "wakeall" but i have no idea how to wake just one computer from list or with manually defined interface and mac
curl -XPOST -d '' -k -u "$key":"$secret" "https://$opnsenseIP:port/api/wol/wol/wakeall"

with getHost i can see from output that correct interface is selected with defined mac and description
curl -XPOST -d '' -k -u "$key":"$secret" "https://$opnsenseIP:port/api/wol/wol/getHost/$uuid"
getHost output:
....."lan":{"value":"correct interface name","selected":1}....."mac":"correct mac","descr":"my description"}}

many thanks


December 31, 2019, 03:40:54 AM #2 Last Edit: December 31, 2019, 03:43:52 AM by maweber

#Will trigger an existing uuid:
POST /wol/wol/set {uuid: 6def5e9b-ebb5-409d-ab52-912c06be7dc2}

#Will trigger a manual/undefined wake:
POST /wol/wol/set {wake: {interface: "opt22", mac: "b4:2e:99:30:da:dd"}}

#Will add a new host to the list:
POST /wol/wol/addHost {host: {interface: "opt22", mac: "b4:2e:99:30:da:dd", descr: "My Hamster"}}


The stuff in brackets is the body of the post, a json encoded object (not array).
So except the basic auth, and the endpoint (ie. "/wol/wol/set"), all variables seem to be going into the body.

It is easy to sniff into the structure via browser dev tools. Some things are more structured than the DOCS show.

It's been a while since this thread but in case anyone stumbles across it: https://gist.github.com/derhelge/1ce6d31f106beea37dfcb36591ac63a7 There is a small Powershell script. We use it to be able to continue using WOL via SCCM / configmgr.