I'm using Invoke-Restmethod to upload a file to Octoprint, however I'm getting an error back of "No file to upload and no folder to create". I've taken a network trace and viewing the POST data with the file upload documentation (File operations β OctoPrint master documentation) and I'm not seeing anything off. The gcode is definitely in the body between the boundary and I see the filename being posted as well.
POST /api/files/local HTTP/1.1
Host: octodev
X-Api-Key: MYKEYHERE
User-Agent: Mozilla/5.0 (Windows NT 10.0; Microsoft Windows 10.0.19041; en-US) PowerShell/7.2.0
I tried bumping up the file API logging but it doesn't seem to give me anymore information (doesn't seem like it notices an attempt at all). API key works, I can interact with other REST endpoints without issue.
You need a filepath option as part of the form data, possibly instead of where you have filename="roo2.gcode", does switching to filepath="roo2.gcode" work?
Recently worked with someone on discord with a similar issue, trying to use JavaScript to upload a file manually - this was the result
This might be wrong - I'm just looking at the code & docs, maybe it was something specific to the library being used at the time, not the actual http request.
I thought maybe the extra dashes before the last boundary was causing it to not interpret the file contents, however if I remove those Octoprint becomes unstable. I can't reach the web interface and SSH is iffy. I noticed in a network trace that the Pi sends tcp window resizes a the way down to zero and net traffic slows down.