Jump to content
Ultimaker Community of 3D Printing Experts

POST print_job with nodeJS

Recommended Posts


I try to start a print job over the API of my Ultimaker 3. I read the example in this post

 and tried to port the code from python to nodeJS, but the POST request is just hanging.



var request = require("request");
var fs = require('fs');
var formData = {
    "file": {
      value: fs.createReadStream('C:\\Users\\efentzahn\\IKIMUNI_Schornstein_simple2.gcode'),
      options: {
        filename: 'IKIMUNI_Schornstein_simple2.gcode'

request.post( {url: '',
              auth: { user: '45fa38b52ea5a998c085145930356bd6', pass: '63bb0fc18a39ba7c787805e80f0be1211144f4083de634deb57f7e7819a640ec', sendImmediately: false},
              formData: formData},
function(error, response, body){
    if (!error && response.statusCode == 201){
        console.log("Print started.");
        console.log('Code : ' + response.statusCode)
        console.log('error : ' + error)
        console.log('body : ' + body);


The auth is working. It must be a problem with the formData. Have anyone tried this with nodeJS until now?

Share this post

Link to post
Share on other sites

It's been a while since I developed anything in Node, but in general the code looks ok.


How long have you waited? Maybe you're trying to post a very big file?


As a first thing, I would try doing an /api/v1/auth/verify request. Just as a sanity check to test if you are correctly submitting the username and password.


If that is working, maybe you can try some of the easier calls that don't need a multipart form, like setting the LED brightness?


Otherwise, you may need to check your multipart form code. I know this can be complicated in many languages and it looks like the syntax is ok, but you never know.

(I used Google to find this: https://github.com/request/request#multipartform-data-multipart-form-uploads )

Share this post

Link to post
Share on other sites

The login is working and doing PUT request like pause a print works fine in node.js.

The file is 340kbyte "big". That should be transmitted very fast. After a few seconds (maybe 10?) node ends with the error: "socket hang up".


I think the problem is the multipart form part, but i have no clue what it is exactly. I already googled a lot and the code posted above is developed with this example from the request library. But the correct names and needed fields in the multipart form is dependent to the Ultimaker API. So, I have the strong feeling that a Ultimaker developer have to take a look at the code.

Share this post

Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

  • Our picks

    • Ultimaker Cura | a new interface
      We're not only trying to always make Ultimaker Cura better with the usual new features and improvements we build, but we're also trying to make it more pleasant to operate. The interface was the focus for the upcoming release, from which we would already like to present you the first glance. 
        • Like
      • 86 replies
    • "Back To The Future" using Generative Design & Investment Casting
      Designing for light-weight parts is becoming more important, and I’m a firm believer in the need to produce lighter weight, less over-engineered parts for the future. This is for sustainability reasons because we need to be using less raw materials and, in things like transportation, it impacts the energy usage of the product during it’s service life.
        • Like
      • 12 replies

Important Information

Welcome to the Ultimaker Community of 3D printing experts. Visit the following links to read more about our Terms of Use or our Privacy Policy. Thank you!