REST API: error refreshing snap selecting channel

Hi all,
i’ve followed the REST API documented here [1], to refresh a snap selecting a dedicated channel (i.e. beta)

The snapd daemon send a 400 error code: "unsupported option provided for multi-snap operation"

I’ve encountered this response following these commands:

  • installed “classic” and “curl” to be able to send command to snapd.
  • (from inside a classic environment) logged-in using:

(classic)domotz@localhost:~$ sudo curl --unix-socket /run/snapd.socket -H “Content-Type: application/json” -X POST -d ‘{“username”: “xxxxx”, “password”: “yyyyy” }’ http://localhost/v2/login | jq .

  • installed a snap using the API:

sudo curl --unix-socket /run/snapd.socket -H “Content-Type: application/json” -X POST -d ‘{“action”: “install”, “snaps”: [“hello”]}’ http://localhost/v2/snaps | jq .

  • tried to refresh the snap with this command

sudo curl --unix-socket /run/snapd.socket -H “Content-Type: application/json” -X POST -d ‘{“action”: “refresh”, “snaps”: [“hello”], “channel”: “beta” }’ http://localhost/v2/snaps | jq .

The response is:

{
“type”: “error”,
“status-code”: 400,
“status”: “Bad Request”,
“result”: {
“message”: “unsupported option provided for multi-snap operation”
}
}

Am I using APIs correctly or is there a bug?
Thanks,

Francesco

[1] https://github.com/snapcore/snapd/wiki/REST-API

Wow, I’m so sorry I missed this!

I’ve answered essentially the same question here.