Android Question Post Table

sinuser

Member
Licensed User
Longtime User
Hi,
i need to post a log table for c# webservice, which is the best methods?
create a file and post multipart?
thanks
 

Yayou49

Active Member
Licensed User
Hi,

Here is an example used, in my case, to send a picture to a webservice.
Sure you can adapt this code for a txt file.

B4X:
'handle the picture from the camera
Dim Fic1 As String = "FicName"
    Dim Myout As OutputStream
    Myout.InitializeToBytesArray(0)
    Myout = File.OpenOutput(File.DirRootExternal, "/" & Fic1 & ".jpg", False)
     
    Myout.WriteBytes(Data, 0, Data.Length)
    Myout.Close
 
    Dim hc As OkHttpClient
    hc.Initialize("hc")
 
    'Add files
    Dim files As List
    files.Initialize
    Dim fd As FileData
    fd.Initialize
    fd.Dir = File.DirRootExternal
    fd.FileName = Fic1 & ".jpg"
    fd.KeyName = "Photo"
    fd.ContentType = "application/octet-stream"
    files.Add(fd)

    'Add name / values pairs (parameters) (empty in my case)
    Dim NV As Map
    NV.Initialize

    Dim req As OkHttpRequest
 
    Dim URL As String = "Your Webservice URL"
 
    req = MultipartPost.CreatePostRequest(URL, NV, files)
    req.SetHeader("Authorization",Main.MyToken)
    hc.Execute(req, 1)


Hope it can help you ....
 
Upvote 0

sinuser

Member
Licensed User
Longtime User
yes thank you so much, do you think the best choice is to create a txt or xml file from the table and post via this system?
sorry for my bad English
 
Upvote 0

Yayou49

Active Member
Licensed User
yes thank you so much, do you think the best choice is to create a txt or xml file from the table and post via this system?
sorry for my bad English

It depends on your target.
Both are possible.
Your choice must be up to your need according on what you will manage on Windows side.
 
Upvote 0
Cookies are required to use this site. You must accept them to continue using the site. Learn more…