I try to add an address to a server with this API, but the problem is it's returning an Error 415 message in the images, but I don't send any media files, I just send a JSON map like shown in the images as well.

although it works in the postman it returns this error in the emulator.

this is the function of the API request

  Future addAddress(Placemark placemark) async {
try {
  String token = DataSaver.getData(tokenKey);

  Uri uri = Uri.parse("$url$usersTag/$uid$addressTag");
  var response = await http
    headers: <String, String>{
      'userId': uid,
      "Authorization": "Bearer $token",
    body: json.encode(AddressCredintials.fromPlacemark(placemark)),
      .timeout(timeoutDuration, onTimeout: () {
    log("request TimeOut");
    return http.Response('Error', 408);

  if (response.statusCode == 200) {
    log("address added");
  } else {
} catch (e) {
} }

this is the class I am using.

class AddressCredintials {
  String govID;
  String cityID;
  String? villageID;
  String street;
  String? building;
  String? apartment;

      required this.street,
      required this.cityID,
      required this.govID,

  factory AddressCredintials.fromPlacemark(Placemark placemark) {
    return AddressCredintials(
        street: placemark.street,
        cityID: placemark.city.id,
        govID: placemark.government.id,
        apartment: placemark.apartment,
        building: placemark.building,
        villageID: placemark.village != null ? placemark.village!.id : null);

  Map toJson() {
    return {
      "governorateId": govID,
      "cityId": cityID,
      "areaId": villageID,
      "street": street,
      "buildingNo": building,
      "appartmentNo": apartment

Solution 1: Leo Rodrigo

Add to the header this value "content-type": "application/json"

and in case your response is also a json add this "accept": "application/json"