Proxmox API /agent/file-write

Etienne

New Member
Mar 22, 2020
4
0
1
26
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

About

The Proxmox community has been around for many years and offers help and support for Proxmox VE, Proxmox Backup Server, and Proxmox Mail Gateway.
We think our community is one of the best thanks to people like you!

Get your subscription!

The Proxmox team works very hard to make sure you are running the best software and getting stable updates and security enhancements, as well as quick enterprise support. Tens of thousands of happy customers have a Proxmox subscription. Get yours easily in our online shop.

Buy now!