Paste content into files via LXD API is not working but CLI works fine

Hey,

Running the following command via cli works fine:
lxc exec container -- sh -c "echo Test > /root/test"

But when I send the command via Rest API ( /1.0/instances/<name>/exec) it wont create the file.
{"command":["sh -c \"echo Test > \/root\/test\""],"wait-for-websocket":false,"record-output":false,"interactive":false}

JSON is valid, API reported zero errors.

{"type":"async","status":"Operation created","status_code":100,"operation":"/1.0/operations/bcaea00c-d27d-4d91-99c9-e5104f8a6613","error_code":0,"error":"","metadata":{"id":"bcaea00c-d27d-4d91-99c9-e5104f8a6613","class":"task","description":"Executing command","created_at":"2020-05-13T10:20:21.032260568Z","updated_at":"2020-05-13T10:20:21.032260568Z","status":"Running","status_code":103,"resources":{"containers":["/1.0/containers/container"],"instances":["/1.0/instances/container"]},"metadata":null,"may_cancel":false,"err":"","location":"none"}}

Anyone got an idea why it fails?

That command should be `[“sh”, “-c”, “echo test > /root/test”]

1 Like

Works fine. Thanks.