Android Question httputils2 POSTSTRING instead of post, it does a GET

abilio486software

Active Member
Licensed User
Hi,

for some reason, httputils job stops sending POST bu a GET

B4X:
    xml = "<TAX>\n"
    xml = xml & "<NF>" & "12345" & "</NF>\n"
    xml = xml & "<ID>" & ph.getSettings("android_id") & "</ID>\n"
    xml = xml & "</TAX>\n"
   
    j.Initialize("Job", Me)
    j.PostString("http://fdsfdsfsd.com/restxxxxx.php",xml)
                               
    Wait For (j) JobDone(j As HttpJob)
    If j.Success Then
        Log("answer:" & j.GetString)
       
       
         ....
 

teddybear

Well-Known Member
Licensed User
Hi,

for some reason, httputils job stops sending POST bu a GET

B4X:
    xml = "<TAX>\n"
    xml = xml & "<NF>" & "12345" & "</NF>\n"
    xml = xml & "<ID>" & ph.getSettings("android_id") & "</ID>\n"
    xml = xml & "</TAX>\n"
  
    j.Initialize("Job", Me)
    j.PostString("http://fdsfdsfsd.com/restxxxxx.php",xml)
                              
    Wait For (j) JobDone(j As HttpJob)
    If j.Success Then
        Log("answer:" & j.GetString)
      
      
         ....
Why do you think it is GET, did you see the request method on php Server?
 
Upvote 0

abilio486software

Active Member
Licensed User
1. You should spend 3 minutes and learn how to use smart strings.
2. HttpJob.PostString sends a POST request. It doesn't matter whether it is http or https.
In fact, apache (or B4X) was converting POST into GET, because we have tested.
The solution was to install a new certificate on the server.
After that new SSL, everithing is working perfectly and the source code is now sending again a POST as it was in the past.
I don't have any explanation.
Could be a man in the middle???
But it's solved.
 
Upvote 0

teddybear

Well-Known Member
Licensed User
In fact, apache (or B4X) was converting POST into GET, because we have tested.
It is interesting how you have tested it? what is console.log($_SERVER['REQUEST_METHOD']) on PHPserver or log(req.Method) on B4Jserver?
The result I tested is POST
 
Upvote 0

mcqueccu

Well-Known Member
Licensed User
Longtime User
I once had such issue where I was sending a POST request to an endpoint on my server using okHttputils2 but the server was reporting GET.

The mistake I made was, I did not specify the full url.

Instead of https://some domain.com/index.php
I used: https://some domain.com/

Without the index.php, assuming the app will automatically read the index file. So even though the request was received by the index.php it was treating it as GET until I updated the URL with the index.php file
 
Upvote 0
Top