[英]Android - Jsoup connect succeeds on emulator but fails on device
When trying to login using Jsoup connect on a website (in order to retrieve cookies for future requests), the request works fine on the emulator but not on my device.当尝试在网站上使用 Jsoup connect 登录时(以便为将来的请求检索 cookie),该请求在模拟器上运行良好,但在我的设备上运行不正常。 Here is a piece of code :这是一段代码:
// login data passed as a body using application/xxx-form-urlencoded
Map<String, String> data = new HashMap<>();
Map<String, String> headers = new HashMap<>();
Connection conn = Jsoup.connect(login_url)
.data(list)
.headers(headers)
.method(Connection.Method.POST)
.ignoreHttpErrors(true);
Connection.Response res = conn.execute();
Everything is fine on the emulator : it returns a 200 with the cookies I am expecting.模拟器上的一切都很好:它返回 200 和我期待的 cookie。 On device it returns a 404 : according to some tests on Postman it means that the login fails, but I can't figure out why... Both connection parameters are identical.在设备上它返回 404 :根据对 Postman 的一些测试,这意味着登录失败,但我不知道为什么......两个连接参数是相同的。
The SDK version is ok, I tried with other methods (HttpUrlConnection) but it won't work either.. SDK版本没问题,我尝试了其他方法(HttpUrlConnection),但它也不起作用..
Is there something I am missing ?有什么我想念的吗?
Thanks for the help !谢谢您的帮助 !
我做了一个 HttpUrlConnection ,它解决了我的问题。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.