API Question/Gcode-upload
I am trying to upload Gcode to the server with a python script/websocket but I can't seem to get it to work.
The server gives the following response:
{"callback_id":548,"data":{"msgId":"5f02f5e8-c801-4b1a-ad99-16831c1dc45c","ok":true},"session":"86!i%U6509!CIDPeLF44w!wI1o4Lmj7e"}
and then sends
{"callback_id":-1,"data":[{"data":{"finished":true,"msgId":"5f02f5e8-c801-4b1a-ad99-16831c1dc45c","ok":false,"progress":0.0},"event":"progressUpdate"}],"eventList":true}
Can anyone help with this?
I have sucessfully logged into the server via websocket and I can ping the server, move the printer etc. Uploading the file through the GUI also works.
The Websocket command that I am using is:
{"action":"importURL","data":{"folder":"visitenkarten","files":{"name":"newfiletoprint","url":'+Folderstring+',"job":true} },"printer":"testdrucker","callback_id":548}
where Folderstring is the Folderpath. I have tried to use / instead of \\ but wasn't sucessful.
The Websocket command that I am using is:
{"action":"importURL","data":{"folder":"visitenkarten","files":{"name":"newfiletoprint","url":'+Folderstring+',"job":true} },"printer":"testdrucker","callback_id":548}
where Folderstring is the Folderpath. I have tried to use / instead of \\ but wasn't sucessful.
Folderstring='"folder://I:\\Uni\\Hochschule\\PA_Visitenkarten\\CFFFP_Visitenkarte_duenn.gcode"'
The server gives the following response:
{"callback_id":548,"data":{"msgId":"5f02f5e8-c801-4b1a-ad99-16831c1dc45c","ok":true},"session":"86!i%U6509!CIDPeLF44w!wI1o4Lmj7e"}
and then sends
{"callback_id":-1,"data":[{"data":{"finished":true,"msgId":"5f02f5e8-c801-4b1a-ad99-16831c1dc45c","ok":false,"progress":0.0},"event":"progressUpdate"}],"eventList":true}
Can anyone help with this?
Comments
I am a bit confused what goes into the "folder" argument of the "importURL" command.
I created a project, a directory and a Gcode group in the printer settings all with the same name but the "getFolders" command can't seem to find any of them.
{"callback_id":540,"data":{"folders":[],"ok":true},"session":"CWs4Ztw#8iZutajc8ux$BA!!UoW5143S"}
After sending you get progressUpdate with msgId from first response about the progress. The response you got means it failed importing. If you check the logs/server.log file you should also see the reason why it failed. So either something I do not see or different computers.
For real uploading using a webform post you need the non websocket solution described in API or that you see in the simplify upload example in the docs section on our homepage.
The server is running on the posting pc. I got a different response from the server, which I think means that the upload was successful (?) but I can't see where it has uploaded the files. The server logs do not contain any useful information, just Baudrate errors since the printer isn't connected.
Command that I used is the same as in my initial post exept the added [].
Server response:
{"callback_id":-1,"data":[{"data":{"finished":false,"msgId":"9b8287d9-784a-4802-8d01-19b833ce79ce","ok":true,"progress":50.0},"event":"progressUpdate"},{"data":{"finished":true,"msgId":"9b8287d9-784a-4802-8d01-19b833ce79ce","ok":true,"progress":100.0},"event":"progressUpdate"}],"eventList":true}
I have seen the simplify upload example and will try that if everything fails.
After looking into your command you send I see an error for files. You send it as object but is must be an array of objects since you can import several files at once. Maybe that is preventing the import.
The full command that I am sending is (I tried making it somehat better readable, I send it without the whitespace) :
"data": {"folder":"models",
"files":[{ "name":"newfiletoprint",
"url":"folder://I:/Uni/Hochschule/PA_Visitenkarten/CFFFP_Visitenkarte_duenn.gcode",
"job":false
}]
},
"printer":"testdrucker",
"callback_id":548}
My only other guess would be that somehow in line 2 ' "folder":"models" ' is wrong. Is the folder argument related to the Gcode groups?
"folder" is the assigned group in case "job":true and must exist before uploading. Set it to "#" to use the default folder.
If I set "folder" as
and look into the Errors logs I get
File not found: folder://i/Uni/Hochschule/PA_Visitenkarten/CFFFP_Visitenkarte_duenn.g
If I set folder as "folder://I:\Uni\Hochschule\PA_Visitenkarten\CFFFP_Visitenkarte_duenn.g
I get
Bad URI syntax: bad or invalid port number: niochschuleA_VisitenkartenFFFP_Visitenkarte_duenn.g
I think this should not be an issue on my Raspberry Pi where I inted to run the whole script but is there a workaround for windows?
The problems were:
In the files argument, "name" has to be left empty.
In the files argument, folder in "url" needs to be manually added and referenced by id ( number 2 above).
name can be left empty but also works with name. Important part should be that the file must have one of the supported extensions (added to docs). If left empty the name from url is used instead.