B4J Question Problem to access waze service with httpUtils2 program

gragey

Member
Licensed User
Longtime User
Hello
Sorry for my english
I try to access some data with B4A and/or B4X program on a web site (www.waze.com)
The request which is OK via a brower htttp is :

https://www.waze.com/row-RoutingMan...4&to=x:5.074009895324707+y:47.323297853574104

I use the example program httpUtils2 whith a small modification :

Region Project Attributes
#MainFormWidth: 500
#MainFormHeight: 500
#LibraryName: jHttpUtils2
#LibraryVersion: 1.02
#MergeLibraries: false
#End Region

Sub Process_Globals
Private fx As JFX
Private MainForm As Form
Private ImageView1 As ImageView
End Sub

Sub AppStart (Form1 As Form, Args() As String)
MainForm = Form1
'MainForm.RootPane.LoadLayout("Layout1") 'Load the layout file.
MainForm.Show
ImageView1.Initialize("")
MainForm.RootPane.AddNode(ImageView1, 0, 0, MainForm.Width, MainForm.Height)
Dim job1, job2, job3 As HttpJob
'Send a POST request
job1.Initialize("Job1", Me)
job2.Initialize("Job2", Me)
job1.PostString("https://www.waze.com/row-rtserver/web/TGeoRSS?","ma=600&mj=100&mu=100&left=4.866085&right=4.892349&bottom=45.901924&top=45.955057")
job2.PostString("https://www.waze.com/row-RoutingManager/routingRequest?","from=x%3A4.988061299999999+y%3A45.8205974&to=x%3A5.074009895324707+y%3A47.323297853574104")
' job2.Download("https://www.waze.com/row-RoutingMan...4&to=x:5.074009895324707+y:47.323297853574104")


End Sub

Sub JobDone (Job As HttpJob)
Log("JobName = " & Job.JobName & ", Success = " & Job.Success)
If Job.Success = True Then
Select Job.JobName
Case "Job1", "Job2"
'print the result to the logs
Log(Job.GetString)
Case "Job3"
'show the downloaded image
ImageView1.SetImage(Job.GetBitmap)
End Select
Else
Log("Error: " & Job.ErrorMessage)
End If
Job.Release
End Sub



And I have the error "Forbidden" for the job2 but the job1 request is OK

If you ave a solution ?

Thank you very much
 

Erel

B4X founder
Staff member
Licensed User
Longtime User
Please use [code]code here...[/code] tags when posting code.

The browser sends a GET request. So you should use Download instead of PostString.

This code works:
B4X:
Dim j As HttpJob
   j.Initialize("j", Me)
   j.Download("https://www.waze.com/row-RoutingManager/routingRequest?from=x%3A4.988061299999999+y%3A45.8205974&to=x%3A5.074009895324707+y%3A47.323297853574104")
   j.GetRequest.SetHeader("User-Agent", "Mozilla/5.0 (compatible; MSIE 10.0; Windows NT 6.2; Trident/6.0)")
 
Upvote 0
Cookies are required to use this site. You must accept them to continue using the site. Learn more…