[SOLVED] Injecting QEMU SSH keys via the API

judahnator

New Member
Jun 16, 2022
8
0
1
Hello, forum!

I am running into a bit of trouble. I am using the API to configure a VM (PUT `/api2/json/nodes/{node}/qemu/{vmid}/config`, as documented here).
I receive the following error, only when the 'sshkeys' parameter is present:

Code:
HTTP/1.1 400 Parameter verification failed.

If I omit the 'sshkeys' parameter the request works fine. I was hoping that someone might be able to point me in the right direction on how this feature works. Would anyone happen to have a code snippet that is working for them? Perhaps the keys need to be encoded or terminated in some way.
 
Ah-ha! That was the trick. URL-encoding the string was the ticket.

For anyone in the future that runs into this problem and is using PHP, don't use the `urlencode()` method. You need to use the `rawurlencode()` method here.
 
Glad to hear that it works, please mark this thread as solved so that others with the same problem can find it more easily in the future :)