Unable to get a response from API

i made an attempt to connect to your api but we’re not getting a response the below are the codes :

static Future<dynamic> fetchOptimizedRoute(
      List<DeliveryDayDetailsModel> locations) async {
    const username = 'USERNAME';
    const password = 'PASSWORD';
    const endpoint = 'https://api.routexl.nl/tour/';
    final List<Map<String, dynamic>> locations0 = [
      {"address": "Riyadh", "lat": 24.7136, "lng": 46.6753},
      {"address": "Mecca", "lat": 21.3891, "lng": 39.8579},
      {"address": "Taif", "lat": 21.2854, "lng": 40.6316},
      {"address": "Dammam", "lat": 26.4207, "lng": 50.0888},
    ];
    final response = await http.post(
      Uri.parse(endpoint),
      headers: {
        'Authorization':
            'Basic ${base64Encode(utf8.encode('$username:$password'))}',
        'Content-Type': 'application/json',
      },
      body: jsonEncode({'locations': locations0}),
    );

    if (response.statusCode == 200) {
      final data = jsonDecode(response.body);
      print(data);
      // _drawRoute(data['route'], data['total_distance'], data['total_time']);
    } else {
      print('Error fetching optimized route: ${response.statusCode}');
    }
  }

Unfortunately, we’re not experts in your specific programming language, but you may need to adjust how your request body is formatted. It looks like the issue might be related to the content-type header in your request. While your locations parameter should indeed be JSON-encoded, the RouteXL API requires the request itself to use application/x-www-form-urlencoded as the Content-Type.