Stop/Resume vehicle using Traccar API using simple java script

Prince Rajput6 years ago

we found a lot of people want to test rest api to stop vehicle even i was also looking before some time.
please find below proper working code to call api for engine stop/resume using traccar services.

<!DOCTYPE html>
<html>
  <head>
    <meta charset="utf-8">
    <title>try traccar api</title>
  </head>
  <body>
    <script src="https://code.jquery.com/jquery-2.2.2.min.js" charset="utf-8"></script>
    <script type="text/javascript">
      // var name = "Prince Rajput";
      // var uid = "+91 8864908528";
      $.ajax({
        type: 'post',
        url: 'http://ip:8082/api/commands/send',
        // please replace IP to your orginal IP
        headers: {
            "Authorization": "Basic " + btoa("username:password")
            // above line please replace username and password to orginal username , password.
        },
        contentType:"application/json",
        data:JSON.stringify({
                   deviceId: 2,
        // type: "engineStop"
        type: "engineResume"
        }),
        success: function (response) {
            console.log(response);
        }
      });

    </script>
  </body>
</html>

please use above given code to stop/resume vehicle.