Better understanding HttpUtils.PostString

darkuni

Member
Licensed User
Longtime User
Alright .. I have the "MS SQL Demo" code all ported over and working in my proof of concept app.

I feel like I'm missing something crucial from an "understanding" standpoint.

I understand what "HttpUtils.PostString" does. I understand how to retrieve the "query" parameter on the other side.

What I don't quite understand is - where is the parameter name "query" set at?

What if I want ONE job to use "query" and another job to use a different parameter name? I don't see where this is set at. It isn't in the ServerURL being used, it isn't part of the parameters for the PostString method...

... and while I have you all here (hehhehee), what are you guys using for the passing of username and password in this sort of situation? Are you sending in plain text? So like:

HttpUtils.PostString("Job1", "http://localhost/login.aspx", "username|password")

... and you handle the splitting of the query value ...? Are you encoding the username|password string before sending (base64, etc)? Best practice ideas?

Thanks for the help!
 

darkuni

Member
Licensed User
Longtime User
There is no "query" parameter. The query parameter is an optional way to pass the query with a GET request (see the comment in the ASP code).

I did see that ... but it didn't totally make sense to me as written.

So what you are saying is:

1) Whatever is put in the third parameter of the PostString is passed purely as a string via the POST method. There is no key value pair there as with a querysting?

2) If I want to use key value pairs, I should simply call the URL with querystring built in and leave the third parameter blank?

Finally, what happens on the callback if I use querystrings? If I was going to do that, I would do it programmatically:

serverurl="http://localhost/process.apx"
Httputils.PostString("Job1", serverurl & "username=" & <username variable> & "&password=" & <password variable>, "")

.. but later on when doing the Job Complete, I couldn't just check against serverurl right? I'd have to use the FULL querystring version? I'd have to build and compare the same value?

serverurl="http://localhost/process.apx" & "username=" & <username variable> & "&password=" & <password variable>
Httputils.PostString("Job1", serverurl , "")

I'm curious why HttpUtils.IsSuccess doesn't use the JOB name vice the URL ...?

Thanks again!
 
Upvote 0

Erel

B4X founder
Staff member
Licensed User
Longtime User
1) That is correct.
2) Yes, though it is also possible to send the key/value pairs as the post data (third argument). With PHP these values will appear under $_POST.
3) You can use HttpUtils.Tasks.Get(0) to get the first (and only) url. You can see an example here: OAuth 2.0 / Google web services tutorial
4) A Job can contain many Urls.
 
Upvote 0

darkuni

Member
Licensed User
Longtime User
Okay, I'm feeling better in knowledge level now.

Couple last filler questions ...

1) The "job name" is arbitrary - it can be anything, right? So if a job can have multiple URLs, these are really stored as sort of an array or name/value pairs itself - but only ONE callback is done regardless?
2) Multiple URLs are handled in parallel? ANY url return within a collection under a single job could come back at any time? Are the calls threaded with each return calling the same sub isolated in its own space?

Appreciate the help.
 
Upvote 0
Top