I am trying to intercept http POST method in WebView android, but not able to find any suitable method for the same. In API 11 there is a method shouldInterceptRequest, but it gives only webviewq and url as parameters so cater only GET request, it doesnot provide POST body data and request type indicator.
My question : Is there any way to override this method in android NDK ? or if i can pass a flag which identify request and also i can provide POST data.
Also if you have any other solution, tell me.
Related
I have a JSON API URL "http://myurl/getDataMethod" this takes a parameter "parameter1". How can I call this API in browser to view its result? Can I use JSFiddle to see the result on runtime? If not then can you provide code for viewing the result in Android app?
I tried calling the API in android App but I got error java.io.FileNotFoundException:, I don;t know why. Also my parameter is having # symbol which is getting converted to %40 when I call the URL through code in APP. I just want to view the data from this API by passing parameter, please help/advise. Thanks.
You can always use an API Tester tool like Postman for testing/viewing the response received from an API. Also if your API method is GET, you can even use a browser by passing the relevant query parameters.
When you try to call an API from a browser, the entire URL gets Encoded so # becomes %40
Use Postman software to access your api and its data anytime before you start coding so as to know the data structure and flow.
Refer to the Postman tutorials or official documentation to learn more about the working
Postman documentation link:
https://learning.getpostman.com/docs/postman/api-documentation/documenting-your-api/
My scenario is this: we point the user to a form where they fill in the data (3DSecure) and then POST, the website then POSTS the response to a callback URL - this response is what I want to capture. WebView.shouldInterceptRequest() can get the headers but not the content (Why, Google?). I tried this link and it can get the POST data that the user sends. Is there any way to use Javascript to catch the POST data being received to a callback of my choosing?
I saw this post from 5 years ago and the man resorted to POSTing the response back to a server and then getting the contents from the phone. This is far from ideal. Surely there's a newer solution?
shouldInterceptRequest() mentions that a response contains the "response information or null if the WebView should load the resource itself", how do I get it so that the WebView shouldn't load the resource itself? The source code seems to return null always.
I used this gentleman's library: https://github.com/LivotovLabs/3DSView
If one was looking to do this with something other than 3DSecure they could use it as a template.
I'm developing an Android application which communicates with (our own) API. It was meant to use the API in manipulative requests with the request method POST and at not-manipulative requests GET (as it should be in RESTful applications).
To authenticate or add parameters to the request, the HTTP request body has been used (in both GET and POST requests). (YES, it is possible and allowed to add a request body to GET requests per HTTP definition (see e.g. this post)). The post generally says, that it is possible to add a request body, but the server may not use it during the request.
The problem is, that the request method is always set to POST, no mather if I set it to GET anywhere during the connection configuration, even if the getRequestMethod does return GET after setting it to GET via setRequestMethod("GET").
The android application uses the HttpsURLConnection (which is an extended class from HttpURLConnection, so it should behave similary).
By calling these methods, a request body will be attended:
https.setDoInput(true);
OutputStream os = https.getOutputStream();
os.write(outputInBytes);
os.close();
And by calling https.setRequestMethod("GET"), the request method should be set to GET.
After a little investigating, the line OutputStream os = https.getOutputStream(); sets the request method to POST, afterwards I set it to GET again and it remains GET till the end of the connection (as returned by https.getRequestMethod())
But in the end the server receives the request with the request method POST.
So my specific questions are:
Is there a possible workaround / solution for this problem?
Is it really that bad to add a request body to a GET request?
Currently I have just set all requests to POST, so there is no problem with it (and I wouldn't have a problem to leave it this way, but for several reasons I would like to know for sure that there is no other way to fix this problem)
Edit: The documentation of the getOutputStream() method says:
The default request method changes to "POST" when this method is called.
By default the HttpURLConnection is a GET Method (getDoInput() is true by default).
If you use setDoOutput(true) it will become a POST method.
If you need another method (PUT, DELETE, etc...) then you will use setRequestMethod(string).
And of course you have to select the method you want before the connect() method
i'm working with webview recently and i found 2 methods to load an URL in webView.
For postUrl() the doc said clearly it sends a POST request, but it didn't say anything about loadUrl().
can anybody tell me anything about it?
Currently I am working on payment integration for native android app after send the request it have given me post back url with some attributes as success/fail response. I can't understand that how can I get those post back url attributes values using WebView . If any one know,
Please suggest me some idea for that.