Proxmox API /agent/file-write

Etienne

New Member
Mar 22, 2020
4
0
1
27
Hi,

how can i send amulti line text threw the api /agent/file-write?

If i send

-d content="test \n test2"

there is no new line in the written document just test without test2 in the next line

Thank you in advanced
 
Hi,

how can i send amulti line text threw the api /agent/file-write?

Your message is transmitted as base64 encoded, so you can't send new line normally

but you can do a newline with -e option that 'enable interpretation of backslash escapes' so try this way

Bash:
pvesh create /nodes/{node}/qemu/{vmid}/agent/file-write --content "$(echo -e 'TEST1\nTEST2')" --file "/tmp/newline"
 
Thats exectly how i tryed it but i get the response
Code:
status: 400,
statusText: 'Parameter verification failed.',

in nodejs with the code
,

Code:
  const test = await fetch(
    `https://server:8006/api2/json/nodes/{node}/qemu/{qemu}/resize`,
    {
      method: "PUT",
      headers: {
        Cookie: `PVEAuthCookie=${ticket}`,
        CSRFPreventionToken: CSRFPreventionToken
      },
      data: "disk=scsi0&size=+1G"
    }
  );

and also tried it in postman

Code:
https://server:8006/api2/json/nodes/node/qemu/qemu/resize?disk=scsi0&size=+1G

Post man error:

Code:
"errors": {
        "size": "value does not match the regex pattern"
}

My Hard disk: disk.png
 
can you try urlencoding the parameter in case your tooling does not do that automatically? (the '+' should be '%2B')
 
  • Like
Reactions: Moayad