Error code 500 with Bing Maps Multi Itinerary Optimization API

Stock Control 5 Reputation points
2023-05-11T09:07:59.1233333+00:00

Hi,

I have a problem with the Bing Maps Multi Itinerary Optmization API. I am using Power Automate to send a POST request to the MIO API, with the following URI:

https://dev.virtualearth.net/REST/V1/Routes/OptimizeItineraryAsync?key=Ap5Jzixxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx

It works 95% of the time, but sometimes it returns "Request is not completed", and after a few minutes "statusCode":500,"statusDescription":"Something went wrong!". I send the following Body in the POST request:

{
  "agents": [
    {
      "name": "1055",
      "shifts": [
        {
          "startTime": "2023-04-26T06:00:00",
          "startLocation": {
            "latitude": 51.94125748,
            "longitude": 5.19734907
          },
          "endTime": "2023-04-26T16:00:00",
          "endLocation": {
            "latitude": 51.94125748,
            "longitude": 5.19734907
          },
          "breaks": [
            {
              "startTime": "2023-04-26T06:30:00",
              "endTime": "2023-04-26T16:00:00",
              "duration": "01:00:00"
            }
          ]
        }
      ],
      "capacity": [
        32
      ]
    },
    {
      "name": "1057",
      "shifts": [
        {
          "startTime": "2023-04-26T07:30:00",
          "startLocation": {
            "latitude": 51.94125748,
            "longitude": 5.19734907
          },
          "endTime": "2023-04-26T15:00:00",
          "endLocation": {
            "latitude": 51.94125748,
            "longitude": 5.19734907
          },
          "breaks": [
            {
              "startTime": "2023-04-26T08:00:00",
              "endTime": "2023-04-26T15:00:00",
              "duration": "00:45:00"
            }
          ]
        }
      ],
      "capacity": [
        32
      ]
    },
    {
      "name": "1058",
      "shifts": [
        {
          "startTime": "2023-04-26T06:30:00",
          "startLocation": {
            "latitude": 51.94125748,
            "longitude": 5.19734907
          },
          "endTime": "2023-04-26T11:00:00",
          "endLocation": {
            "latitude": 51.94125748,
            "longitude": 5.19734907
          },
          "breaks": [
            {
              "startTime": "2023-04-26T07:00:00",
              "endTime": "2023-04-26T11:00:00",
              "duration": "00:30:00"
            }
          ]
        }
      ],
      "capacity": [
        32
      ]
    },
    {
      "name": "1059",
      "shifts": [
        {
          "startTime": "2023-04-26T06:30:00",
          "startLocation": {
            "latitude": 51.94125748,
            "longitude": 5.19734907
          },
          "endTime": "2023-04-26T16:00:00",
          "endLocation": {
            "latitude": 51.94125748,
            "longitude": 5.19734907
          },
          "breaks": [
            {
              "startTime": "2023-04-26T07:00:00",
              "endTime": "2023-04-26T16:00:00",
              "duration": "01:00:00"
            }
          ]
        }
      ],
      "capacity": [
        32
      ]
    }
  ],
  "itineraryItems": [
    {
      "name": "#1",
      "openingTime": "2023-04-26T00:00",
      "closingTime": "2023-04-26T23:59",
      "dwellTime": "00:30:00",
      "priority": 100,
      "quantity": [
        138
      ],
      "depot": true,
      "location": {
        "latitude": 51.94125748,
        "longitude": 5.19734907
      }
    },
    {
      "name": "#2",
      "openingTime": "2023-04-26T06:00:00",
      "closingTime": "2023-04-26T11:00:00",
      "dwellTime": "01:00:00.00",
      "priority": 1,
      "quantity": [
        -8
      ],
      "location": {
        "latitude": 50.88073,
        "longitude": 4.70584
      },
      "dropOffFrom": [
        "SoLow Distributiecentrum"
      ]
    },
    {
      "name": "#3",
      "openingTime": "2023-04-26T00:00:00",
      "closingTime": "2023-04-26T23:59:00",
      "dwellTime": "01:00:00.00",
      "priority": 1,
      "quantity": [
        -6
      ],
      "location": {
        "latitude": 51.2222,
        "longitude": 4.50178
      },
      "dropOffFrom": [
        "SoLow Distributiecentrum"
      ]
    },
    {
      "name": "#4",
      "openingTime": "2023-04-26T07:00:00",
      "closingTime": "2023-04-26T11:00:00",
      "dwellTime": "01:00:00.00",
      "priority": 1,
      "quantity": [
        -8
      ],
      "location": {
        "latitude": 52.6304932,
        "longitude": 4.74955654
      },
      "dropOffFrom": [
        "SoLow Distributiecentrum"
      ]
    },
    {
      "name": "#5",
      "openingTime": "2023-04-26T00:00:00",
      "closingTime": "2023-04-26T23:59:00",
      "dwellTime": "01:00:00.00",
      "priority": 1,
      "quantity": [
        -12
      ],
      "location": {
        "latitude": 52.5090866,
        "longitude": 4.947688
      },
      "dropOffFrom": [
        "SoLow Distributiecentrum"
      ]
    },
    {
      "name": "#6",
      "openingTime": "2023-04-26T05:00:00",
      "closingTime": "2023-04-26T12:00:00",
      "dwellTime": "01:00:00.00",
      "priority": 1,
      "quantity": [
        -8
      ],
      "location": {
        "latitude": 53.2187767,
        "longitude": 6.56545162
      },
      "dropOffFrom": [
        "SoLow Distributiecentrum"
      ]
    },
    {
      "name": "#7",
      "openingTime": "2023-04-26T07:30:00",
      "closingTime": "2023-04-26T12:00:00",
      "dwellTime": "01:00:00.00",
      "priority": 1,
      "quantity": [
        -8
      ],
      "location": {
        "latitude": 53.20058,
        "longitude": 5.793882
      },
      "dropOffFrom": [
        "SoLow Distributiecentrum"
      ]
    },
    {
      "name": "#8",
      "openingTime": "2023-04-26T07:00:00",
      "closingTime": "2023-04-26T11:00:00",
      "dwellTime": "01:00:00.00",
      "priority": 1,
      "quantity": [
        -4
      ],
      "location": {
        "latitude": 52.21765,
        "longitude": 6.89861965
      },
      "dropOffFrom": [
        "SoLow Distributiecentrum"
      ]
    },
    {
      "name": "#9",
      "openingTime": "2023-04-26T00:00:00",
      "closingTime": "2023-04-26T12:00:00",
      "dwellTime": "01:00:00.00",
      "priority": 1,
      "quantity": [
        -10
      ],
      "location": {
        "latitude": 51.9642067,
        "longitude": 6.2903223
      },
      "dropOffFrom": [
        "SoLow Distributiecentrum"
      ]
    },
    {
      "name": "#10",
      "openingTime": "2023-04-26T00:00:00",
      "closingTime": "2023-04-26T11:00:00",
      "dwellTime": "01:00:00.00",
      "priority": 1,
      "quantity": [
        -9
      ],
      "location": {
        "latitude": 52.21486,
        "longitude": 5.96168137
      },
      "dropOffFrom": [
        "SoLow Distributiecentrum"
      ]
    },
    {
      "name": "#11",
      "openingTime": "2023-04-26T00:00:00",
      "closingTime": "2023-04-26T23:59:00",
      "dwellTime": "01:00:00.00",
      "priority": 1,
      "quantity": [
        -10
      ],
      "location": {
        "latitude": 52.51246,
        "longitude": 6.09615135
      },
      "dropOffFrom": [
        "SoLow Distributiecentrum"
      ]
    },
    {
      "name": "#12",
      "openingTime": "2023-04-26T00:00:00",
      "closingTime": "2023-04-26T11:00:00",
      "dwellTime": "01:00:00.00",
      "priority": 1,
      "quantity": [
        -9
      ],
      "location": {
        "latitude": 51.4387,
        "longitude": 5.478569
      },
      "dropOffFrom": [
        "SoLow Distributiecentrum"
      ]
    },
    {
      "name": "#13",
      "openingTime": "2023-04-26T00:00:00",
      "closingTime": "2023-04-26T23:59:00",
      "dwellTime": "01:00:00.00",
      "priority": 1,
      "quantity": [
        -10
      ],
      "location": {
        "latitude": 51.4795151,
        "longitude": 5.65455437
      },
      "dropOffFrom": [
        "SoLow Distributiecentrum"
      ]
    },
    {
      "name": "#14",
      "openingTime": "2023-04-26T07:00:00",
      "closingTime": "2023-04-26T11:00:00",
      "dwellTime": "01:00:00.00",
      "priority": 1,
      "quantity": [
        -27
      ],
      "location": {
        "latitude": 50.78205,
        "longitude": 5.59718
      },
      "dropOffFrom": [
        "SoLow Distributiecentrum"
      ]
    },
    {
      "name": "#15",
      "openingTime": "2023-04-26T06:00:00",
      "closingTime": "2023-04-26T12:00:00",
      "dwellTime": "01:00:00.00",
      "priority": 1,
      "quantity": [
        -9
      ],
      "location": {
        "latitude": 51.3690262,
        "longitude": 6.168621
      },
      "dropOffFrom": [
        "SoLow Distributiecentrum"
      ]
    }
  ],
  "roadnetwork": "true",
  "costvalue": "TravelTime"
}

As i said before, it returns "Requested is not completed" and "statusCode":500,"statusDescription":"Something went wrong!". As you can see, I am not above the hard limit of 20 itinerary items for the Basic Key. The weird thing is, if I delete any one of the itinerary items, the request does work. I have tested other json schema's that returned a error code 500, and the same thingapplied to them; Deleting any one of the itinerary itmes results in it workin. Can anybody help me?

Azure Maps
Azure Maps
An Azure service that provides geospatial APIs to add maps, spatial analytics, and mobility solutions to apps.
633 questions
Windows Maps
Windows Maps
A Microsoft app that provides voice navigation and turn-by-turn driving, transit, and walking directions.
253 questions
0 comments No comments
{count} votes

2 answers

Sort by: Most helpful
  1. rbrundritt 16,066 Reputation points Microsoft Employee
    2023-05-11T15:01:43.1866667+00:00

    I believe the issue is that you have 4 agents and are using a basic key. In the documentation it states "The API supports up to 3 itineraryAgents and 20 itineraryItems per request for Basic Bing Maps accounts." The request you provided in your post has 4 agents (issue) and 15 items (good).

    2 people found this answer helpful.

  2. Stock Control 5 Reputation points
    2023-05-16T07:24:44.4433333+00:00

    Hi @rbrundritt & @IoTGirl ,

    First of all, thanks a lot for your help.

    Sorry for my slow response, i have been away for a couple of days.

    I can confirm that we do not deliver straight to the Eggert Winkelcetrum, but rather to the Nieuwstraat. I've tested the same JSON schema with the new coordinates (

                        "latitude": 52.507965,
                        "longitude": 4.946727
    
    

    ) and it now works!

    Many thanks again for your in-depth help and knowledge to the both. The tip I have for people running into this issue is; check the coordinates for all your itineraryItems to see if they are not in an unreachable spot. I am going to check all of the coordinates for my itineraryItems to see if they are in a reachable place.

    1 person found this answer helpful.