trying to use api sendkey via ansible uri, anyone has used before?

Martin_Etcheverri

New Member
Jul 10, 2020
1
0
1
49
i need to send keys to the vm when it boots .
looking to the api , i found
HTTP: PUT /api2/json/nodes/{node}/qemu/{vmid}/sendkey

i am trying to do something like that:
- name: send keys
uri:
url: "{{ proxmox_rest_api_url }}/{{ proxmox_node }}/qemu/{{proxmox_vmid}}/sendkey"
validate_certs: no
use_proxy: no
method: PUT
body_format: json
body:
{
"key": "{{ item }}",
"node": "{{ proxmox_node }}",
"vmid": "{{ proxmox_vmid }}",
}
headers:
Content-Type: "application/json"
Cookie: "{{ ticket }}"
CSRFPreventionToken: "{{ ticket }}"
loop:
- kp_enter
- kp_enter
- spc
- spc

And i get this response:
"Status code was -1 and not [200]: An unknown error occurred: expected string or bytes-like object",
 
this sounds like an error from the Ansible module.. maybe there's some way to get more detailed output from it?

anyhow, ticket and CSRF token are two different things, setting the same value for both of them is incorrect for sure ;)