khwarizmi Active Member Licensed User Longtime User Jan 28, 2020 #1 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
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 Jan 28, 2020 #2 That's not how urls work. You should read the basics here: https://en.wikipedia.org/wiki/URL If you wish to GET data, you will need to send your parameters in a more standardized way. The most common way is to send as query parameters, like this: https://www.example.com/checklogin?user=ali&pw=ass A less common, but perfectly valid if you are sure what the server expects, is this: https://www.example.com/checklogin/ali/ass Most likely you will want to use my first example. Upvote 0
That's not how urls work. You should read the basics here: https://en.wikipedia.org/wiki/URL If you wish to GET data, you will need to send your parameters in a more standardized way. The most common way is to send as query parameters, like this: https://www.example.com/checklogin?user=ali&pw=ass A less common, but perfectly valid if you are sure what the server expects, is this: https://www.example.com/checklogin/ali/ass Most likely you will want to use my first example.
khwarizmi Active Member Licensed User Longtime User Jan 28, 2020 #3 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
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
DonManfred Expert Licensed User Longtime User Jan 28, 2020 #4 Use Poststring instead of download! As written you are defining the http job wrong. Upvote 0
Sandman Expert Licensed User Longtime User Jan 28, 2020 #5 kattah said: I work as part of a team and I have to work with JSON array for input and output. Click to expand... 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.) kattah said: this url (http://192.168.1.13:3000/cstmrlgn/{"user":"ali","pw":"sss"} ) is working in the normal web browser and in the Postman Click to expand... 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
kattah said: I work as part of a team and I have to work with JSON array for input and output. Click to expand... 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.) kattah said: this url (http://192.168.1.13:3000/cstmrlgn/{"user":"ali","pw":"sss"} ) is working in the normal web browser and in the Postman Click to expand... 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.
khwarizmi Active Member Licensed User Longtime User Jan 28, 2020 #6 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
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)
DonManfred Expert Licensed User Longtime User Jan 28, 2020 #7 without knowing the server side script it is hard to give any congrete advice. "cstmrlgn" seems to be not existent or not reachable. Upvote 0
without knowing the server side script it is hard to give any congrete advice. "cstmrlgn" seems to be not existent or not reachable.
mcqueccu Expert Licensed User Longtime User Jan 28, 2020 #9 kattah said: 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 Click to expand... Whats the content of js Upvote 0
kattah said: 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 Click to expand... Whats the content of js
khwarizmi Active Member Licensed User Longtime User Jan 29, 2020 #10 thanks, Now I made a modification to the code and put the web address on the form: http://192.168.1.13:3000/cstmrlgn/checklogin/ali/sss and now it is working I temporarily postponed research on the subject, but will return to it later. Upvote 0
thanks, Now I made a modification to the code and put the web address on the form: http://192.168.1.13:3000/cstmrlgn/checklogin/ali/sss and now it is working I temporarily postponed research on the subject, but will return to it later.