Help with Connecting API to Image Picker for Image Analysis in Flutter App

Actions & Logic

Hello everyone,

I'm building my first app and struggling to connect my API correctly. The goal is to allow the user to take a photo, then send it for analysis through the Foodvisor API. However, I'm running into issues with 403 errors, indicating a problem with the image format.

Has anyone encountered similar issues or have any suggestions on how to correctly format the image for this API? Any guidance would be greatly appreciated!

Thank you!

What have you tried so far?
  • Image Selection via Image Picker:

    • L'utilisateur choisit une image via le widget Image Picker.

  • Convertir l'Image en Base64 (Custom Action):

    • Lorsqu'une image est sélectionnée, la Custom Action convertImagePathToBase64 est déclenchée.

    • Cette action prend le chemin de l'image (imagePath) fourni par l'Image Picker, puis lit l'image et la convertit en une chaîne base64.

    • Cette conversion est nécessaire car l'API Foodvisor attend l'image au format base64.

  • Stockage de l'Image Encodée:

    • Le résultat de la conversion (image en base64) est stocké dans une variable d'état (par exemple, FFAppState().encodedImage) pour pouvoir être utilisée ultérieurement dans l'appel API.

  • Appel de l'API Foodvisor:

    • Une fois l'image convertie et stockée en base64, une action supplémentaire est configurée pour appeler l'API Foodvisor en utilisant la variable FFAppState().encodedImage.

    • L'appel est effectué via une requête POST, envoyant l'image encodée au format JSON comme requis par l'API.

Did you check FlutterFlow's Documentation for this topic?
No
1