How do I take forward a session from a authenticator POST request into a GET request in JAVA?

huangapple go评论88阅读模式
英文:

How do I take forward a session from a authenticator POST request into a GET request in JAVA?

问题

请参考此链接:https://stackoverflow.com/questions/63011809/java-equivalent-of-a-curl-cookie-statement/63012623?noredirect=1#comment111607622_63012623

我有一段 Java 代码,其中一个 POST 请求通过使用上述链接中提到的 MgntUtils 库正常工作。

以下是代码部分:

HttpClient client = new HttpClient();

client.setContentType("application/json; charset=utf-8");

client.setConnectionUrl("http://egurl/app/app1/session/login");

client.sendHttpRequest(HttpMethod.POST, "{\"username\":\"acd\",\"password\":\"pwd\",\"isPasswordEncrypted\":\"false\"}");

我需要使用相同的会话并将其用于从不同的 URL 获取一些数据,例如:http://egurl/app/app1/param/paramgrp/1234

是否有一种方法可以使用会话来完成这个任务。我在使用 Java 中的 GETPOST 方面相对较新,所以需要一些帮助。

谢谢。

英文:

please refer to this <https://stackoverflow.com/questions/63011809/java-equivalent-of-a-curl-cookie-statement/63012623?noredirect=1#comment111607622_63012623>

I have a Java code where a post request works perfectly as follows using MgntUtils library as mentioned in the above link.

here the code :

HttpClient client = new HttpClient();

client.setContentType(&quot;application/json; charset=utf-8&quot;);

client.setConnectionUrl(&quot;http://egurl/app/app1/session/login&quot;);

client.sendHttpRequest(HttpMethod.POST, &quot;{\&quot;username\&quot;:\&quot;acd\&quot;,\&quot;password\&quot;:\&quot;pwd\&quot;,\&quot;isPasswordEncrypted\&quot;:\&quot;false\&quot;}&quot;);

i need to use the same session and use it to get some data from a different URL eg. http://egurl/app/app1/param/paramgrp/1234

is there a way i can use session to get this done. i am fairly new to GET and POST in JAVA so need some help.

Thanks/

答案1

得分: 0

这可以通过使用jsoup封装类来实现。请访问此链接以获得更好的理解。

英文:

This can be achieved using jsoup wrapper classes. please follow this link to have a better understanding.

huangapple
  • 本文由 发表于 2020年7月27日 20:25:25
  • 转载请务必保留本文链接:https://go.coder-hub.com/63115309.html
匿名

发表评论

匿名网友

:?: :razz: :sad: :evil: :!: :smile: :oops: :grin: :eek: :shock: :???: :cool: :lol: :mad: :twisted: :roll: :wink: :idea: :arrow: :neutral: :cry: :mrgreen:

确定