salesagility / SuiteCRM

SuiteCRM - Open source CRM for the world
https://www.suitecrm.com
GNU Affero General Public License v3.0
4.26k stars 2.03k forks source link

Unable to upload images in API_REST V4.1 through flutter mobile app #10448

Open alexoberco opened 2 weeks ago

alexoberco commented 2 weeks ago

Issue

I am trying to set an entry in a module in my suitecrm instance the method am using is this

static Future<bool> createTurnoVigilante({
    required String nombre,
    required String inicioFinalTurno,
    required int turnoExtra,
    required String rostroVigilanteBase64, // Imagen en Base64
    required String latitud,
    required String longitud,
    required String uuid,
  }) async {
    final String? decryptedSessionId = await AuthenticationService.getDecryptedSessionId();
    final String? suitecrmUrl = await _storage.read(key: 'suitecrm_url');

    if (decryptedSessionId == null || suitecrmUrl == null) {
      print("No se pudo obtener la sesión o la URL de SuiteCRM.");
      return false;
    }

    final Uri endpointUri = Uri.parse('$suitecrmUrl/service/v4_1/rest.php');
    final response = await http.post(
      endpointUri,
      headers: {'Content-Type': 'application/x-www-form-urlencoded'},
      body: {
        'method': 'set_entry',
        'input_type': 'JSON',
        'response_type': 'JSON',
        'rest_data': jsonEncode({
          'session': decryptedSessionId,
          'module_name': 'tuvi_turnos_vigilantes',
          'name_value_list': [
            {'name': 'name', 'value': nombre},
            {'name': 'mao_inicio_final', 'value': inicioFinalTurno},
            {'name': 'mao_turno_extra', 'value': turnoExtra.toString()},
            {'name': 'mao_rostro_vigilante', 'value': rostroVigilanteBase64}, // Image in Base64
            {'name': 'latitude_c', 'value': latitud},
            {'name': 'longitude_c', 'value': longitud},
            {'name': 'mao_uuid_c', 'value': uuid},
          ],
        }),
      },
    );

    if (response.statusCode == 200) {
      final data = json.decode(response.body);
      if (data['id'] != null) {
        return true;
      }
    }
    return false;
  }

also I try to make the request in postman and in both the entry is created but the image in the module don't display any image and in the data base the value in the field of the base64 image is the base64 code of the image, maybe am missing something?

Possible Fix

No response

Steps to Reproduce the Issue

1.
2.
3.
...

Context

No response

Version

7.1.0

What browser are you currently using?

Chrome

Browser Version

No response

Environment Information

PHP

Operating System and Version

Windows 10