How to send gcode via API?

Hi

disclaimer: I know little about 3d printers or motor control systems.

But I'm loving this software. it is so cool  :-)

fyI: My project is a completely non standard 'thing' and Im pressing repetier into non standard stuff, but I think this is a general question:

How can I (or is it possible to) send a request with gcode to the API?

Having read docs I was assuming I could do something like  this:


(I'm using curl or somesuch so encoding aside)

but any options I tried dont work.

How to do this please?

Thanks

c.

Comments

  • You were close by. Docs say
    http://localhost:3344/printer/api/<slug>?a=<websocket command>&data=<json object properly url-escaped>&apikey=<API key>>

    but your data is not a json object that is url encoded. The unencoded json string would be
    {"cmd":"G1 X50"}

    put url encoding to it and you get
    %7B%22cmd%22%3A%22G1+X50%22%7D
    making your command


  • thanks very much for reply which helped pinpoint the problem. I've got it now.

    it wasnt the encoding - I was calling it from php so had urlencode(json_encode())


    it was the 'cmd' string. I hadnt understood that part, so in effect what I had for data was the gcode:

    %7B%22G1+X50%22%7D


    thanks again. no doubt I'll be back soon!

    c.
  • Hello, I am having the same issue, send or command by browser:


    and I get a home on all axes of my 3D printer, but when I put it as information in iftt via webhooks (url) + get + application json I don't get feedback on voice command, any suggestions?
    thank you!
  • 192.168.x.x is a private local network and not reachable by external servers in intranet. To do that you would need to add port forwarding in your router and replace it by the router ip/port instead. Depending on your internet provider this might work or not (shared ip v4/DS light). Also ip might change over time so you would require a dynip service to always point to correct ip. If you do that you should at least secure server with password or anyone can use it then as you published it in internet. Even better if you use https also that is tricky. pi image allows that with a self signed (untrusted) certificate. But that would at least protect transfer of apikey.
Sign In or Register to comment.