Facing requires classic confinement error

As per the documentation, https://github.com/snapcore/snapd/wiki/REST-API#post-v2snaps
I am trying to install kubectl with the curl command

sudo curl --unix-socket /run/snapd.socket -H "Content-Type: application/json" -X POST -d '{"action": "install", "snaps": ["kubectl"], "classic": true}'  http://localhost/v2/snaps | jq .

but it gives an error like:

  "type": "error",
  "status-code": 400,
  "status": "Bad Request",
  "result": {
    "message": "snap \"kubectl\" requires classic confinement",
    "kind": "snap-needs-classic",
    "value": "kubectl"

This is not spelled out in the wiki docs, but to install a classic snap, you can’t use the “multi-snaps” endpoint /v2/snaps, you need to use /v2/snaps/kubectl with the classic option, otherwise it’s unclear with the current API design which snap in the snaps list classic: true applies to.


sudo curl --unix-socket /run/snapd.socket -H "Content-Type: application/json" -X POST -d '{"action": "install", "classic": true}'  http://localhost/v2/snaps/kubectl | jq .

Thanks for your reply, its working now.