Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Open
alexoberco opened this issue Jun 14, 2024 · 0 comments
Open

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

alexoberco opened this issue Jun 14, 2024 · 0 comments
Labels
Type: Bug Bugs within the core SuiteCRM codebase

Comments

@alexoberco
Copy link

alexoberco commented Jun 14, 2024

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

@alexoberco alexoberco added the Type: Bug Bugs within the core SuiteCRM codebase label Jun 14, 2024
@alexoberco alexoberco changed the title Unable to upload images in API_REST V4.1 through fluuter mobile aplication Unable to upload images in API_REST V4.1 through flutter mobile app Jun 14, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Type: Bug Bugs within the core SuiteCRM codebase
Projects
None yet
Development

No branches or pull requests

1 participant