Android Question Issue: PUT Request with text/xml Headers in B4A

Orion3

New Member
Hi everyone,

I'm facing an issue while trying to make an HTTP PUT request in B4A, where I need to send data in XML format to a specific server. Here's the code snippet I'm using:



code:
Sub EnviarPUT(ipp As String, comando As String)

    comando = "<Request><Playback>" & comando & "</Playback></Request>"
    Dim url As String = "http://" & ipp & ":" & port & "/api/Replay/%7B%7D/Playback/"
  
    Dim Job As HttpJob
    Job.Initialize("RequisicaoPUT", Me)
  
    ' Set Content-Type as text/xml
    Job.GetRequest.SetContentType("text/xml")
  
    ' Send the PUT request with the XML content
    Job.PutString(url, comando)
End Sub

The problem is that the server seems to reject the PUT request when the Content-Type is set to text/xml. I have tested the same request in other environments (like Postman and Python), and it works fine with the same header.

Additionally, I tried manually building the request using sockets, but I still couldn't get it to work.

Questions:​

  • Has anyone faced this issue when working with PUT requests in B4A?
  • Is there anything specific I should consider when setting headers for PUT requests in B4A?
  • Are there any alternative libraries you recommend for handling HTTP requests with full header customization?
Thanks in advance for your help! 😊
 

drgottjr

Expert
Licensed User
Longtime User
when something "doesn't work", you need to post the log (and, depending on the error, unfiltered log is best). you should also post your manifest.

the code snippet you've posted is not complete or correct. it's not clear how you know the server "seems" to reject the request. you might want to export the project and post it.
 
Upvote 0

aeric

Expert
Licensed User
Longtime User

Questions:​

  • Has anyone faced this issue when working with PUT requests in B4A?
  • Is there anything specific I should consider when setting headers for PUT requests in B4A?
  • Are there any alternative libraries you recommend for handling HTTP requests with full header customization?

Answers:​

  • No
  • No unless authentication like token or API key is required
  • No, OkHttpUtils is the one I use all the time and works 100%
 
Last edited:
Upvote 0
Top