Android Question Body ContentType not supported

Bernaert Dominique

Member
Licensed User
Longtime User
Hi,

I'm having a problem uploading an image to a REST-api.
I get the following error Body contentType 'multipart/form-data;boundary=---------------------------1461124740692' not supported

This is the code I'm using:

B4X:
Dim j As HttpJob
j.Initialize("", Me)
Dim fd As MultipartFileData
       
fd.Initialize
fd.KeyName = "Content"
fd.Dir = Provider.SharedFolder
fd.FileName = tempImageFile
fd.ContentType = "application/octet-stream"
   
j.PostMultipart(Main.BaseUrl & "projects/files/upload_image", CreateMap( "hash": "Test","user": "Hallo"), Array(fd))
j.GetRequest.SetHeader("Authentication", "bearer " & Main.Token)
   
Wait For (j) JobDone(j As HttpJob)
If j.Success Then
    Log(j.GetString)
End If
   
j.Release

I've tried several ContentTypes, but i cannot get it working.

What am i doing wrong?

Thx for some help
 

Bernaert Dominique

Member
Licensed User
Longtime User
Erel,

I tried with ContentType "application/json", but then i get an error message from the REST-api: No mapping for the Unicode character exists in the target multi-byte code page.
 
Upvote 0

EnriqueGonzalez

Well-Known Member
Licensed User
Longtime User
Upvote 1
Top