Android Question Webview problem

gigi0ne

Member
Licensed User
Longtime User
Problem with webview - I have 2 separate pages each with a webview, one displays the products and the second the cart and they are perfectly synchronized.
That is, if I insert a product in the cart from the first window , I find it in the second.

The question now comes ... I have to pick up the cart and if I call the page with the routines that I place below
in fact the cart returns to me (in res, without any errors) .... pity it's empty ..

Why are the two webviews synchronized and this call is not?
I could also fetch the data directly from webview, but I have not found anywhere, how to insert in a string or rather list
(it returns me a json set), the text content of the webview page.

Anyone can give me some info?
Thank's



WebView problem:
Sub ExecuteRemoteQuery(Query As String, JobName As String)
    Dim job As HttpJob
    job.Initialize(JobName, Me)
    job.PostString("https://www.mydomain.it/cart.json", "")
End Sub

Sub JobDone(Job As HttpJob)
    ProgressDialogHide
    If Job.Success Then
        Dim res As String
        res = Job.GetString
        Log("Response from server: " & res)
        Dim parser As JSONParser
        parser.Initialize(res)
        Select Job.JobName
            Case "GETCART"
                Log("GetCart" & res)
             
        End Select
    Else
        Log(Job.ErrorMessage)
        ToastMessageShow("Error: " & Job.ErrorMessage, True)
    End If
    Job.Release
End Sub
 

Andrew (Digitwell)

Well-Known Member
Licensed User
Longtime User
From what you have written, it seems that the problem is with the server not returning any data.

Have you tried using something like Postman to confirm the API works properly?
 
Upvote 0

gigi0ne

Member
Licensed User
Longtime User
From what you have written, it seems that the problem is with the server not returning any data.

Have you tried using something like Postman to confirm the API works properly?

thanks for your answer
the server send data correct but the number of items inside is 0...
if i call the same url on webview i see the json data correct.. with 1 or more items compiled
 
Upvote 0

Andrew (Digitwell)

Well-Known Member
Licensed User
Longtime User
Have you tried GET instead of POST.

as Webview calling a URL uses the GET verb whilst your code shows a POST string.

try changing toJob.download("https://www.mydomain.it/cart.json")
 
Upvote 0

gigi0ne

Member
Licensed User
Longtime User
Have you tried GET instead of POST.

as Webview calling a URL uses the GET verb whilst your code shows a POST string.

try changing toJob.download("https://www.mydomain.it/cart.json")

Have try.... no.. the result is the same.. inside webview i see all items, the same call with job.download or job.poststring
return this string:

{"token":"a17ad29fadc217ef55766e05947eb5b8","note":null,"attributes":{},"original_total_price":0,"total_price":0,"total_discount":0,"total_weight":0.0,"item_count":0,"items":[],"requires_shipping":false,"currency":"EUR","items_subtotal_price":0,"cart_level_discount_applications":[]}

the webview return ... see the image
 

Attachments

  • Untitled - 1.jpg
    Untitled - 1.jpg
    299.3 KB · Views: 62
Upvote 0

gigi0ne

Member
Licensed User
Longtime User
But to me the question comes spontaneously ...

Is it possible that the webview does not have the possibility to return the text it displays on the screen?
something like Webview.GetHtmlText ..

I think the BOSS has to intervene here

Thank's
 
Upvote 0

Andrew (Digitwell)

Well-Known Member
Licensed User
Longtime User
I would still say try using PostMan to make the call. Maybe the webview is adding an additional header such as
accept: application/json
etc
 
Upvote 0

mc73

Well-Known Member
Licensed User
Longtime User
I see different tokens in your screenshots.

Furthermore, I see no post parameters (or get) and your webView page link for viewing a cart. Too little info here.

Now, about getting the source code of your html page, the BOSS is SEARCH.
 
Upvote 0

gigi0ne

Member
Licensed User
Longtime User
this is the problem ..
while the 2 webviews seem connected even if they are 2 calls in 2 different pages (it is probably seen as a single session),
when I use the poststring it is as if another user has connected.

It would all be solved if I could read the page content in a string but I couldn't figure out how
the cart data is returned by simply calling the page /cart which returns a series of data in json format
 
Last edited:
Upvote 0

mc73

Well-Known Member
Licensed User
Longtime User
this is the problem ..
while the 2 webviews seem connected even if they are 2 calls in 2 different pages (it is probably seen as a single session),
when I use the poststring it is as if another user has connected.

It would all be solved if I could read the page content in a string but I couldn't figure out how
the cart data is returned by simply calling the page /cart which returns a series of data in json format
Different session means different session cookie. You should grab the cookie from your webView and enter it to your okHttp call. Perform a search for "get cookies from webView".
Again, you're not presenting any code.
 
Upvote 0
Top