This tutorial describes how to use the Next Token with a custom web service.
This tutorial requires creating a LGDXRobot Cloud API Key but does not require authentication.
Prerequisites
- Create a custom RESTful API for receiving the Next Token by using the following Python script.
from http.server import BaseHTTPRequestHandler, HTTPServer
import json
class Handler(BaseHTTPRequestHandler):
def do_POST(self):
length = int(self.headers['Content-Length'])
body = self.rfile.read(length)
data = json.loads(body)
print(data)
self.send_response(200)
self.end_headers()
self.wfile.write(b'OK')
HTTPServer(('', 8000), Handler).serve_forever()
- Save the script as
server.py and run it using python server.py.
- Create an LGDXRobot Cloud API Key and note the secret key.
- Create a trigger with the following properties:
| Field |
Value |
| Name |
Test |
| URL |
http://127.0.0.1:8000 |
| Method |
POST |
In the body, set the following properties:
| Key |
Value |
| TaskId |
Task ID |
| RobotId |
Robot ID |
| NextToken |
Next Token |

- Create a new flow with two progress steps: Loading and Moving. The Proceed Condition for Loading is API, and the trigger is set to the trigger just created.

- Connect a robot to LGDXRobot Cloud.
Completing the Progress
- Create a new task using the flow just created. The waypoints can be any waypoints in the realm.

- The robot will not move because the current progress is Loading.
- Note the Task ID, Robot ID, and Next Token from the terminal running the Python script.

- In Postman, create a new request
https://localhost:5163/Automation/AutoTasksApi/AutoTaskNext and set the method to POST.
- In the Headers tab, add a new key
X-API-Key and set the value to the API Key.

- In the Body tab, add a JSON object with the following properties:
{
"taskId": <Task ID>,
"robotId": "<Robot ID>",
"nextToken": "<Next Token>"
}

- Click Send.
- The robot will move to the next waypoint.
Aborting the Task
- Create a new task using the flow just created. The waypoints can be any waypoints in the realm.
- The robot will not move because the current progress is Loading.
- Note the Task ID, Robot ID, and Next Token from the terminal running the Python script.

- In Postman, create a new request
https://localhost:5163/Automation/AutoTasksApi/AutoTaskAbort and set the method to POST.
- In the Headers tab, add a new key
X-API-Key and set the value to the API Key.

- In the Body tab, add a JSON object with the following properties:
{
"taskId": <Task ID>,
"robotId": "<Robot ID>",
"nextToken": "<Next Token>"
}

- Click Send.
- The task will be aborted, and an email notification will be sent.