iOS Question Base64 post api

Maicon

Member
Licensed User
Longtime User
Hello Everyone, on Android, I send files to my server through an API passing the base64 of the image in the parameters, when I use the same API to send files via base64 on iOS, if the image is a screenshot, it works perfectly but if the image was taken by the camera and is saved in the gallery, the parameters are not sent



B4X:
' Subroutine for testing the API and sending data
Sub api_teste(file As String)
    ' Debug log
    Log("api")

    ' Display progress message
    config.ProgressMensagemShow("Searching for specialties...")

    ' Initialize HttpJob for the request
    Dim httpRequest As HttpJob
    httpRequest.Initialize("", Me)
    Dim postString As String = $"cpf=${B4XPages.MainPage.usuarioMAP.Get("cpfBeneficiario")}&empresa=1&matricula=${B4XPages.MainPage.usuarioMAP.Get("carteirinha")}&solicitacao=${tipoExame}&anexo=data:application/png;base64,${file}"$

    httpRequest.PostString("https://localhost.com/api/agendamentoExame", postString)

    httpRequest.GetRequest.SetHeader("Authorization", B4XPages.MainPage.token)

    ' Wait for the request response
    Wait For (httpRequest) JobDone(httpRequest As HttpJob)

 
    Log(httpRequest.GetString)
    Log(httpRequest.ErrorMessage)
    Log(httpRequest.Response.StatusCode)

    ' Check if the response was successful
    If httpRequest.Response.StatusCode = 200 And httpRequest.Success Then

    End If

    ' Release the HttpJob
    httpRequest.Release

    ' Hide the progress message
    config.ProgressMensagemHide
End Sub
 
Top