UCI batch JSON_RPC?

I want to retrieve several pieces of information from my openwrt router, for this I used JSON RPC requests like:
curl -H 'Content-Type: application/json' -d '{ "jsonrpc": "2.0", "id": 1, "method": "call", "params": [ "$sessionID", "uci ", "get", { "config": "wireless", "section": "radio0", "option": "ssid" } ] }' http://@ip/ubus

I found that there is a uci batch command and it works perfectly:

uci batch <<EOF
get wireless.default_radio0.ssid
get wireless.default_radio1.ssid
EOF

My question is how to run these commands using uci batch in the form of a JSON RPC request?

The uci batch command is not exposed via JSON RPC. You could simply fetch the complete wireless config by omitting the section and option params, or you could batch the RPC requests themselves.

curl -H 'Content-Type: application/json' -d '[
  { "jsonrpc": "2.0", "id": 1, "method": "call", "params": [ "$sessionID", "uci ", "get", { "config": "wireless", "section": "radio0", "option": "ssid" } ] },
  { "jsonrpc": "2.0", "id": 2, "method": "call", "params": [ "$sessionID", "uci ", "get", { "config": "wireless", "section": "radio1", "option": "ssid" } ] }
]' http://@ip/ubus
2 Likes