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:
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 {
new ApiVerbindung().read("http://192.168.178.64:3344/printer/api/MyPrinter?apikey=fd2f5c16-95fa-4a1b-8953-54b0b40ec9e1&a=listModels&data={}");
} 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