Android Tutorial HttpUtils2 - Web services are now even simpler

jaminben

Member
Licensed User
Longtime User
Hi,

I'm trying to use Download2 to deal with illegal parameter characters like spaces but don't seem to be having any luck.

My code looks like:

B4X:
myJob.Download2("http://someaddress with a few spaces.jpg", Array As String(" ", "%20"))

Is the above code correct or am I missing the point

It works when I pass an address without any spaces but errors out when I do have an address with spaces.

Thanks
 
Last edited:

peacemaker

Expert
Licensed User
Longtime User
How about fixing NulPointerException at
CallSubDelayed2(HttpUtils2Service, "SubmitJob", Me)
?


 

salmander

Active Member
Licensed User
Longtime User
Look few posts back, where Erel has mentioned, it’s a bug in v2.0. He is currently in a process of pushing out an update to B4A. In meantime, he suggested me that download a beta update from the same URL where b4a 2.0 was, instead change the name from b4a_full to beta.exe.

Post back if this helps.
 

peacemaker

Expert
Licensed User
Longtime User
Thanks ! 2.01 indeed works OK with the same source.
 

jaminben

Member
Licensed User
Longtime User

NeoTechni

Well-Known Member
Licensed User
Longtime User

It's %20, not + you need to replace spaces with in most cases
 

Gearcam

Active Member
Licensed User
Longtime User
poststring

Is theire a guide to convert to the new HttpUtils2 post string lines ie.

'Send a POST request
job2.Initialize("Job2", Me)
job2.PostString("http://www.b4x.com/print.php", "first key=first value&key2=value2")


From the old version
HttpUtils.PostString("Job1", ServerUrl, "SELECT MOBusername , MOBpassword FROM MobileUsers where MOBusername ='" & G_Usercode & "'")

It would help me out a lot

Steve
 

CharlesIPTI

Active Member
Licensed User
Longtime User
Still testing FAIL

 

Attachments

  • HttpUtil2Test_fromClass.zip
    12.7 KB · Views: 787

Peter Simpson

Expert
Licensed User
Longtime User
This httputils2 is just awesome

It too late for me to add it my latest project, too much work involved. I must say that it does make calling urls for xml feeds and retrieving images easier than ever.

Good work Erel

Awesome...
 

Gearcam

Active Member
Licensed User
Longtime User
It is almost identical:
B4X:
Dim Job1 As HttpJob
Job1.Initialize("Job1", Me)
Job1.PostString(ServerUrl, "SELECT ...")



Thanks Erel works fine
Any issues with using two or more modules (i will end up with about 10 all with different read writes to different tables in the same database)

Do you use a seperate Sub JobDone (Job As HttpJob) in each module ?

Or just the one in the main module i think for my program it will be easier in each module

Steve
 

Gearcam

Active Member
Licensed User
Longtime User
hi Erel

Now im getting theire

I can get some data like

job1.Initialize("Job1", Me)
job1.PostString(ServerUrl, "SELECT MOBusername , MOBpassword FROM MobileUsers where MOBusername ='" & G_Usercode & "'")

this gives a response like
[{"MOBusername":"123","MOBpassword":"XXXXX"}]

how can i easily either change the request or decode the responce so the two variables are then assined as variables ie MOBusername=123 & MOBpassword=XXXXX

so these can used in further code ?

Steve
 

Gearcam

Active Member
Licensed User
Longtime User
Hi erel
Is their an example of how to do this
Was this how it was done in the original version of httputils as I have tried to use this but get many errors

Steve
 

Gearcam

Active Member
Licensed User
Longtime User
Thanks again Erel
I understand the JSON is not re;ated to the HttpUtils or HttpUtils2
But in the original HttpUtils example you had used the JSON to extract the data which is the part i can not get to run i will retry it all today
Thanks
Steve
 
Cookies are required to use this site. You must accept them to continue using the site. Learn more…