Android Question GET method with JSON array

khwarizmi

Active Member
Licensed User
Longtime User
Hi all

I use this code to get data from a url containing JSON array like this :
http://192.168.1.13:3000/cstmrlgn/{"user":"ali","pw":"sss"}

B4X:
Dim chlog As HttpJob
    chlog.Initialize("checklogin", Me)
    chlog.download2(myurl, Array As String("MyJSON", js))
    ProgressDialogShow("verifying username and password")

always I get error (<pre>Cannot GET /cstmrlgn/</pre> )

thanks in advance
 

Sandman

Expert
Licensed User
Longtime User
Upvote 0

khwarizmi

Active Member
Licensed User
Longtime User
I work as part of a team and I have to work with JSON array for input and output.

this url (http://192.168.1.13:3000/cstmrlgn/{"user":"ali","pw":"sss"} ) is working in the normal web browser and in the Postman
 
Upvote 0

Sandman

Expert
Licensed User
Longtime User
I work as part of a team and I have to work with JSON array for input and output.
That's fine, but you're still doing it wrong. Like @DonManfred indicated, if you need to send a json to the server, you should almost certainly do a POST instead. (There are other alternatives, but they are so rare that we can ignore them in this thread.)

this url (http://192.168.1.13:3000/cstmrlgn/{"user":"ali","pw":"sss"} ) is working in the normal web browser and in the Postman
I strongly doubt that. I mean, I believe you when you say it works. However, I don't believe that's what's happening behind the curtain. My best guess is that Postman et al do some automatic conversion. ("Oh, the user entered data like this, la-di-da, I'll just convert it for them so it works, to-de-loo".) You should try to inspect your network traffic to see what really gets sent when you do a request like that.
 
Upvote 0

khwarizmi

Active Member
Licensed User
Longtime User
thanks Sandman and DonManfred, I Use Poststring instead of download, but I get (<pre>Cannot POST /cstmrlgn/</pre>)

B4X:
Dim job2 As HttpJob
job2.Initialize("job2",Me)
job2.Poststring(myurl,js)
 
Upvote 0

mcqueccu

Well-Known Member
Licensed User
Longtime User


Whats the content of js
 
Upvote 0
Cookies are required to use this site. You must accept them to continue using the site. Learn more…