API Question/Gcode-upload

edited December 2019 in General
I am trying to upload Gcode to the server with a python script/websocket but I can't seem to get it to work.
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 server gives the following response:
and then sends

Can anyone help with this?


  • I got a bit further now. I was missing [] around the files. Now it seems like the upload is sucessfull but I can't find it anywhere on the server.
    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.
  • I think you are using the wrong command.It is named importURL as it downloads from web a file and imports that directly. With the folder syntax you can also import files available in your servers harddisk. It is not able to access files on the posting pc except if it is the same one.

    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. 
  • Thanks for the reply.
    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:

    I have seen the simplify upload example and will try that if everything fails.
  • Yes, that looks like successfull upload. If you see in the folder printer/testdrucker/models there should be a new file at the end with highest number.
    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.
  • I looked into the folder, If I upload files manually using the GUI they appear there, if I try to use the websocket nothing changes. Maybe it is a Windows related issue? 
    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",

    My only other guess would be that somehow in line 2 ' "folder":"models" ' is wrong. Is the folder argument related to the Gcode groups?
  • "job":false means it goes to print queue not into models! So it would end in jobs folder. folder is ignored in this case.
    "folder" is the assigned group in case "job":true and must exist before uploading. Set it to "#" to use the default folder.

  • Thanks. There still seems to be an issue with the url/windows paths:
    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?

  • Got it to work. Took just a few hours together with a friend :)  Would greatly appreciate if you could improve the description of your Server API a bit. Apart from serveral copy paste errors the descriptions could be a bit more specific. The working command is as follows:
    {"action": "importURL", "data": {"folder": "visitenkarten", "files": [{"name": "", "url": "folder://2/Uni/Hochschule/PA_Visitenkarten/CFFFP_Visitenkarte_duenn.gcode", "job": false}]}, "printer": "testdrucker", "callback_id": 548}

    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).
  • Had a look into docs and improved it a bit. But the part with the folder id was already contained.

    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.
Sign In or Register to comment.