How can I change CONTENT-TYPE WebView # PostUrl ()?

in Android WebView.

I am trying to use WebView # postUrl () with postData. but I could not find a way to change the Content-Type of the request. it is always "application / x-www-form-urlencoded".

How to change this?

StringBuilder sb = new StringBuilder(); sb.append("<?xml version=\"1.0\" encoding=\"UTF-8\"?>\r\n"); sb.append("<resource>\r\n"); sb.append("<element a=\"a\" b=\"b\"/>\r\n"); sb.append("</resource>"); String postData = sb.toString(); mWebView.postUrl(url, postData.getBytes()); 

Thanks!

+6
source share
1 answer

From the WebView documentation, it looks like you are stuck with the default content-type . I found this one to help analyze the data at my API endpoint, as I could not change the content-type to application/json or something easier to digest.

0
source

Source: https://habr.com/ru/post/944536/


All Articles