Android Question Content-Type Problem

Ohanian

Active Member
Licensed User
Longtime User
Hi,

i'm trying to post some data to a webservice, this html code works fine :

B4X:
<html>
<head>
    <META http-equiv="Content-Type" content="text/html">
</head>
<body>
<div>
    <form action="http://URL/androidOutput.php?sn=login" method="post">
    <input type="text" name="submit_login" value="1">
    <input type="text" name="username" value="NAME">
    <input type="text" name="password" value="PASS">
    <input type="submit" value="Go">
    </form>
</div>
</body></html>

but i can't me it work in b4a with this code :

B4X:
    Job1.Initialize("Login", Me)

    Job1.PostString("http://URL/androidOutput.php?sn=login", "submit_login=1&username=NAME&password=PASS")

    Job1.ContentType = "text/html"

    Job1.GetRequest.SetHeader("User-Agent", "    Mozilla/5.0 (Windows NT 6.1; WOW64; rv:20.0) Gecko/20100101 Firefox/20.0")

any suggestion?
 

DonManfred

Expert
Licensed User
Longtime User
how look your androidOutput.php like? Please post it here...

This should work when you getting the parameters from $_GET inside the php

B4X:
    Dim job As HttpJob
    job.Initialize(JobName, Me)
    job.download2("http://domain/androidoutput.php", Array As String( _
        "submit_login", "1", _
        "username", "NAME", _
        "password", "PASS", _
        "sn", "login", _
    ))
 
Last edited:
Upvote 0

Ohanian

Active Member
Licensed User
Longtime User

Hi,
i don't have access to the source code.
they said that i have to use the post method, and as i mentioned in the html code i have to set the Content-Type to text/html, when i remove that tag from the html code, the html code fails too.
 
Upvote 0

Ohanian

Active Member
Licensed User
Longtime User
I guess that Job1.ContentType is actually Job1.GetRequest.SetContentType, right?

Hi,

this is the code :
B4X:
    Job1.Initialize("Login", Me)
    Job1.PostString("http://URL/androidOutput.php?sn=login", "submit_login=1&username=USER&password=PASS")
    Job1.GetRequest.SetContentType("text/html")
    Job1.GetRequest.SetHeader("User-Agent", "    Mozilla/5.0 (Windows NT 6.1; WOW64; rv:20.0) Gecko/20100101 Firefox/20.0")
 
Upvote 0
Cookies are required to use this site. You must accept them to continue using the site. Learn more…