Unknown Printer

Hello,

for a school project, we want to create a java app or pc program that connects to the 3D printer using the Repetier Server on Raspberry Pi.

Since we have never worked with apis before, we came across a problem: Even though we have created a printer called "MyPrinter" on our Repetier Server, our programm returns a json object that says {"error":"Unknown printer"}

I hope you can help us as we haven't found anything about that specific problem anywhere else on the internet.


Here is the complete code:

public class ApiVerbindung {

public static void main(String[] args) {
try {
} catch (IOException e) {
e.printStackTrace();
}
}

public void read(String url) throws MalformedURLException, IOException {
HttpURLConnection httpcon = (HttpURLConnection) (new URL(url)).openConnection();
httpcon.setDoOutput(true);
httpcon.setRequestProperty("Accept",  "application/json");
httpcon.connect();
BufferedReader inreader = new BufferedReader(new InputStreamReader(httpcon.getInputStream()));
String decodedString;
while ((decodedString = inreader.readLine()) != null) {

System.out.println(decodedString);

}
}
}



Comments

  • Looks good so far. One thing you need to watch out is that internally we use slug and not printer name to reference the printer. So make sure slug is also MyPrinter and not MyPrinter2. You see it in some URLs and also if you call "/printer/info" on your server instance which gives you a list of all installed printers.
Sign In or Register to comment.