API send GCode issue

Hi,
I'm trying to send GCode using the API, everything seems correct to me as im not getting any errors but it just doesn't work.

I'm trying using the demo printer and my real printer:
http://demo.repetier-server.com:4004/printer/api/Cartesian?apikey=7075e377-7472-447a-b77e-86d481995e7b&a=send&data={"M355 S1"}

Is the data properly encoded? 
This is what its encoded from:
encodeURIComponent('{"M355 S1"}');

Thanks,
Jungle

Comments

  • Ok, so you want to use:

    send

    Parameter: cmd (string) = g-code to execute

    Response

    {}

    Sends a g-code directly to the printer.


    Using the direct call to websocket conversion:
    http://localhost:3344/printer/api/<slug>?a=<websocket command>&data=<json object properly url-escaped>&apikey=<API key>>
    Your solution is nearly correct, except data. The json object unencoded would be
    {"cmd":"M355 S1"}
    encoded
    encodeURIComponent('{"cmd":"M355 S1"}')
    %7B%22cmd%22%3A%22M355%20S1%22%7D

    In Parameter description you see the names of the object as well - here "cmd" which you omitted.

  • Brilliant!
    Thanks for the quick response.
Sign In or Register to comment.