Reorder visits
curl --request POST \
--url https://apiweb.mile.app/api/v4/reorder-visits \
--header 'Authorization: Bearer <token>' \
--header 'Content-Type: application/json' \
--data '
{
"vehicleId": "65c3a1b2c3d4e5f600000001",
"currentCoordinate": "-6.2000,106.8166",
"visits": [
{
"id": "taskId-65c3a1b2c3d4e5f600000011",
"name": "Visit 1",
"address": "Neo Soho, Jakarta Barat",
"coordinate": "-6.1778,106.7905"
},
{
"id": "taskId-65c3a1b2c3d4e5f600000012",
"name": "Visit 2",
"address": "Gambir, Jakarta Pusat",
"coordinate": "-6.1753,106.8269"
}
]
}
'import requests
url = "https://apiweb.mile.app/api/v4/reorder-visits"
payload = {
"vehicleId": "65c3a1b2c3d4e5f600000001",
"currentCoordinate": "-6.2000,106.8166",
"visits": [
{
"id": "taskId-65c3a1b2c3d4e5f600000011",
"name": "Visit 1",
"address": "Neo Soho, Jakarta Barat",
"coordinate": "-6.1778,106.7905"
},
{
"id": "taskId-65c3a1b2c3d4e5f600000012",
"name": "Visit 2",
"address": "Gambir, Jakarta Pusat",
"coordinate": "-6.1753,106.8269"
}
]
}
headers = {
"Authorization": "Bearer <token>",
"Content-Type": "application/json"
}
response = requests.post(url, json=payload, headers=headers)
print(response.text)const options = {
method: 'POST',
headers: {Authorization: 'Bearer <token>', 'Content-Type': 'application/json'},
body: JSON.stringify({
vehicleId: '65c3a1b2c3d4e5f600000001',
currentCoordinate: '-6.2000,106.8166',
visits: [
{
id: 'taskId-65c3a1b2c3d4e5f600000011',
name: 'Visit 1',
address: 'Neo Soho, Jakarta Barat',
coordinate: '-6.1778,106.7905'
},
{
id: 'taskId-65c3a1b2c3d4e5f600000012',
name: 'Visit 2',
address: 'Gambir, Jakarta Pusat',
coordinate: '-6.1753,106.8269'
}
]
})
};
fetch('https://apiweb.mile.app/api/v4/reorder-visits', options)
.then(res => res.json())
.then(res => console.log(res))
.catch(err => console.error(err));<?php
$curl = curl_init();
curl_setopt_array($curl, [
CURLOPT_URL => "https://apiweb.mile.app/api/v4/reorder-visits",
CURLOPT_RETURNTRANSFER => true,
CURLOPT_ENCODING => "",
CURLOPT_MAXREDIRS => 10,
CURLOPT_TIMEOUT => 30,
CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
CURLOPT_CUSTOMREQUEST => "POST",
CURLOPT_POSTFIELDS => json_encode([
'vehicleId' => '65c3a1b2c3d4e5f600000001',
'currentCoordinate' => '-6.2000,106.8166',
'visits' => [
[
'id' => 'taskId-65c3a1b2c3d4e5f600000011',
'name' => 'Visit 1',
'address' => 'Neo Soho, Jakarta Barat',
'coordinate' => '-6.1778,106.7905'
],
[
'id' => 'taskId-65c3a1b2c3d4e5f600000012',
'name' => 'Visit 2',
'address' => 'Gambir, Jakarta Pusat',
'coordinate' => '-6.1753,106.8269'
]
]
]),
CURLOPT_HTTPHEADER => [
"Authorization: Bearer <token>",
"Content-Type: application/json"
],
]);
$response = curl_exec($curl);
$err = curl_error($curl);
curl_close($curl);
if ($err) {
echo "cURL Error #:" . $err;
} else {
echo $response;
}package main
import (
"fmt"
"strings"
"net/http"
"io"
)
func main() {
url := "https://apiweb.mile.app/api/v4/reorder-visits"
payload := strings.NewReader("{\n \"vehicleId\": \"65c3a1b2c3d4e5f600000001\",\n \"currentCoordinate\": \"-6.2000,106.8166\",\n \"visits\": [\n {\n \"id\": \"taskId-65c3a1b2c3d4e5f600000011\",\n \"name\": \"Visit 1\",\n \"address\": \"Neo Soho, Jakarta Barat\",\n \"coordinate\": \"-6.1778,106.7905\"\n },\n {\n \"id\": \"taskId-65c3a1b2c3d4e5f600000012\",\n \"name\": \"Visit 2\",\n \"address\": \"Gambir, Jakarta Pusat\",\n \"coordinate\": \"-6.1753,106.8269\"\n }\n ]\n}")
req, _ := http.NewRequest("POST", url, payload)
req.Header.Add("Authorization", "Bearer <token>")
req.Header.Add("Content-Type", "application/json")
res, _ := http.DefaultClient.Do(req)
defer res.Body.Close()
body, _ := io.ReadAll(res.Body)
fmt.Println(string(body))
}HttpResponse<String> response = Unirest.post("https://apiweb.mile.app/api/v4/reorder-visits")
.header("Authorization", "Bearer <token>")
.header("Content-Type", "application/json")
.body("{\n \"vehicleId\": \"65c3a1b2c3d4e5f600000001\",\n \"currentCoordinate\": \"-6.2000,106.8166\",\n \"visits\": [\n {\n \"id\": \"taskId-65c3a1b2c3d4e5f600000011\",\n \"name\": \"Visit 1\",\n \"address\": \"Neo Soho, Jakarta Barat\",\n \"coordinate\": \"-6.1778,106.7905\"\n },\n {\n \"id\": \"taskId-65c3a1b2c3d4e5f600000012\",\n \"name\": \"Visit 2\",\n \"address\": \"Gambir, Jakarta Pusat\",\n \"coordinate\": \"-6.1753,106.8269\"\n }\n ]\n}")
.asString();require 'uri'
require 'net/http'
url = URI("https://apiweb.mile.app/api/v4/reorder-visits")
http = Net::HTTP.new(url.host, url.port)
http.use_ssl = true
request = Net::HTTP::Post.new(url)
request["Authorization"] = 'Bearer <token>'
request["Content-Type"] = 'application/json'
request.body = "{\n \"vehicleId\": \"65c3a1b2c3d4e5f600000001\",\n \"currentCoordinate\": \"-6.2000,106.8166\",\n \"visits\": [\n {\n \"id\": \"taskId-65c3a1b2c3d4e5f600000011\",\n \"name\": \"Visit 1\",\n \"address\": \"Neo Soho, Jakarta Barat\",\n \"coordinate\": \"-6.1778,106.7905\"\n },\n {\n \"id\": \"taskId-65c3a1b2c3d4e5f600000012\",\n \"name\": \"Visit 2\",\n \"address\": \"Gambir, Jakarta Pusat\",\n \"coordinate\": \"-6.1753,106.8269\"\n }\n ]\n}"
response = http.request(request)
puts response.read_body{
"status": true,
"statusCode": 200,
"data": [
{
"_id": "6af2b3f0bdbc6a64740d8def",
"message": "Success.",
"orderIndex": 17942935361,
"status": true
},
{
"_id": "6af2b3f29c356cd9ef0cc550",
"message": "Success.",
"orderIndex": 17942935362,
"status": true
}
]
}{
"status": false,
"message": "The `current coordinate` format is invalid.",
"failedCode": "route-003"
}Routing
Reorder visits
Finds the best order of the ongoing visits of a driver from the driver’s current position, and saves the new order on the tasks.
It plans one vehicle with the new routing, with currentCoordinate as the hub; this temporary routing result is not listed. The first hub of your account is used.
Requires the route-optimization permission.
POST
/
reorder-visits
Reorder visits
curl --request POST \
--url https://apiweb.mile.app/api/v4/reorder-visits \
--header 'Authorization: Bearer <token>' \
--header 'Content-Type: application/json' \
--data '
{
"vehicleId": "65c3a1b2c3d4e5f600000001",
"currentCoordinate": "-6.2000,106.8166",
"visits": [
{
"id": "taskId-65c3a1b2c3d4e5f600000011",
"name": "Visit 1",
"address": "Neo Soho, Jakarta Barat",
"coordinate": "-6.1778,106.7905"
},
{
"id": "taskId-65c3a1b2c3d4e5f600000012",
"name": "Visit 2",
"address": "Gambir, Jakarta Pusat",
"coordinate": "-6.1753,106.8269"
}
]
}
'import requests
url = "https://apiweb.mile.app/api/v4/reorder-visits"
payload = {
"vehicleId": "65c3a1b2c3d4e5f600000001",
"currentCoordinate": "-6.2000,106.8166",
"visits": [
{
"id": "taskId-65c3a1b2c3d4e5f600000011",
"name": "Visit 1",
"address": "Neo Soho, Jakarta Barat",
"coordinate": "-6.1778,106.7905"
},
{
"id": "taskId-65c3a1b2c3d4e5f600000012",
"name": "Visit 2",
"address": "Gambir, Jakarta Pusat",
"coordinate": "-6.1753,106.8269"
}
]
}
headers = {
"Authorization": "Bearer <token>",
"Content-Type": "application/json"
}
response = requests.post(url, json=payload, headers=headers)
print(response.text)const options = {
method: 'POST',
headers: {Authorization: 'Bearer <token>', 'Content-Type': 'application/json'},
body: JSON.stringify({
vehicleId: '65c3a1b2c3d4e5f600000001',
currentCoordinate: '-6.2000,106.8166',
visits: [
{
id: 'taskId-65c3a1b2c3d4e5f600000011',
name: 'Visit 1',
address: 'Neo Soho, Jakarta Barat',
coordinate: '-6.1778,106.7905'
},
{
id: 'taskId-65c3a1b2c3d4e5f600000012',
name: 'Visit 2',
address: 'Gambir, Jakarta Pusat',
coordinate: '-6.1753,106.8269'
}
]
})
};
fetch('https://apiweb.mile.app/api/v4/reorder-visits', options)
.then(res => res.json())
.then(res => console.log(res))
.catch(err => console.error(err));<?php
$curl = curl_init();
curl_setopt_array($curl, [
CURLOPT_URL => "https://apiweb.mile.app/api/v4/reorder-visits",
CURLOPT_RETURNTRANSFER => true,
CURLOPT_ENCODING => "",
CURLOPT_MAXREDIRS => 10,
CURLOPT_TIMEOUT => 30,
CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
CURLOPT_CUSTOMREQUEST => "POST",
CURLOPT_POSTFIELDS => json_encode([
'vehicleId' => '65c3a1b2c3d4e5f600000001',
'currentCoordinate' => '-6.2000,106.8166',
'visits' => [
[
'id' => 'taskId-65c3a1b2c3d4e5f600000011',
'name' => 'Visit 1',
'address' => 'Neo Soho, Jakarta Barat',
'coordinate' => '-6.1778,106.7905'
],
[
'id' => 'taskId-65c3a1b2c3d4e5f600000012',
'name' => 'Visit 2',
'address' => 'Gambir, Jakarta Pusat',
'coordinate' => '-6.1753,106.8269'
]
]
]),
CURLOPT_HTTPHEADER => [
"Authorization: Bearer <token>",
"Content-Type: application/json"
],
]);
$response = curl_exec($curl);
$err = curl_error($curl);
curl_close($curl);
if ($err) {
echo "cURL Error #:" . $err;
} else {
echo $response;
}package main
import (
"fmt"
"strings"
"net/http"
"io"
)
func main() {
url := "https://apiweb.mile.app/api/v4/reorder-visits"
payload := strings.NewReader("{\n \"vehicleId\": \"65c3a1b2c3d4e5f600000001\",\n \"currentCoordinate\": \"-6.2000,106.8166\",\n \"visits\": [\n {\n \"id\": \"taskId-65c3a1b2c3d4e5f600000011\",\n \"name\": \"Visit 1\",\n \"address\": \"Neo Soho, Jakarta Barat\",\n \"coordinate\": \"-6.1778,106.7905\"\n },\n {\n \"id\": \"taskId-65c3a1b2c3d4e5f600000012\",\n \"name\": \"Visit 2\",\n \"address\": \"Gambir, Jakarta Pusat\",\n \"coordinate\": \"-6.1753,106.8269\"\n }\n ]\n}")
req, _ := http.NewRequest("POST", url, payload)
req.Header.Add("Authorization", "Bearer <token>")
req.Header.Add("Content-Type", "application/json")
res, _ := http.DefaultClient.Do(req)
defer res.Body.Close()
body, _ := io.ReadAll(res.Body)
fmt.Println(string(body))
}HttpResponse<String> response = Unirest.post("https://apiweb.mile.app/api/v4/reorder-visits")
.header("Authorization", "Bearer <token>")
.header("Content-Type", "application/json")
.body("{\n \"vehicleId\": \"65c3a1b2c3d4e5f600000001\",\n \"currentCoordinate\": \"-6.2000,106.8166\",\n \"visits\": [\n {\n \"id\": \"taskId-65c3a1b2c3d4e5f600000011\",\n \"name\": \"Visit 1\",\n \"address\": \"Neo Soho, Jakarta Barat\",\n \"coordinate\": \"-6.1778,106.7905\"\n },\n {\n \"id\": \"taskId-65c3a1b2c3d4e5f600000012\",\n \"name\": \"Visit 2\",\n \"address\": \"Gambir, Jakarta Pusat\",\n \"coordinate\": \"-6.1753,106.8269\"\n }\n ]\n}")
.asString();require 'uri'
require 'net/http'
url = URI("https://apiweb.mile.app/api/v4/reorder-visits")
http = Net::HTTP.new(url.host, url.port)
http.use_ssl = true
request = Net::HTTP::Post.new(url)
request["Authorization"] = 'Bearer <token>'
request["Content-Type"] = 'application/json'
request.body = "{\n \"vehicleId\": \"65c3a1b2c3d4e5f600000001\",\n \"currentCoordinate\": \"-6.2000,106.8166\",\n \"visits\": [\n {\n \"id\": \"taskId-65c3a1b2c3d4e5f600000011\",\n \"name\": \"Visit 1\",\n \"address\": \"Neo Soho, Jakarta Barat\",\n \"coordinate\": \"-6.1778,106.7905\"\n },\n {\n \"id\": \"taskId-65c3a1b2c3d4e5f600000012\",\n \"name\": \"Visit 2\",\n \"address\": \"Gambir, Jakarta Pusat\",\n \"coordinate\": \"-6.1753,106.8269\"\n }\n ]\n}"
response = http.request(request)
puts response.read_body{
"status": true,
"statusCode": 200,
"data": [
{
"_id": "6af2b3f0bdbc6a64740d8def",
"message": "Success.",
"orderIndex": 17942935361,
"status": true
},
{
"_id": "6af2b3f29c356cd9ef0cc550",
"message": "Success.",
"orderIndex": 17942935362,
"status": true
}
]
}{
"status": false,
"message": "The `current coordinate` format is invalid.",
"failedCode": "route-003"
}Body
application/json