apache-httpclient-4.x

How to POST JSON object to spring controller?

青春壹個敷衍的年華 提交于 2020-01-05 23:29:16
问题 I have spring controller: @RequestMapping(value = "/add", method = RequestMethod.POST, consumes = "application/json") public @ResponseBody ResponseDto<Job> add(User user) { ... } I can POST the object like this with APACHE HTTP CLIENT: HttpPost post = new HttpPost(url); List nameValuePairs = new ArrayList(); nameValuePairs.add(new BasicNameValuePair("name", "xxx")); post.setEntity(new UrlEncodedFormEntity(nameValuePairs)); HttpResponse response = client.execute(post); In controller I get user

How to POST JSON object to spring controller?

╄→尐↘猪︶ㄣ 提交于 2020-01-05 23:23:29
问题 I have spring controller: @RequestMapping(value = "/add", method = RequestMethod.POST, consumes = "application/json") public @ResponseBody ResponseDto<Job> add(User user) { ... } I can POST the object like this with APACHE HTTP CLIENT: HttpPost post = new HttpPost(url); List nameValuePairs = new ArrayList(); nameValuePairs.add(new BasicNameValuePair("name", "xxx")); post.setEntity(new UrlEncodedFormEntity(nameValuePairs)); HttpResponse response = client.execute(post); In controller I get user

How to POST JSON object to spring controller?

淺唱寂寞╮ 提交于 2020-01-05 23:22:31
问题 I have spring controller: @RequestMapping(value = "/add", method = RequestMethod.POST, consumes = "application/json") public @ResponseBody ResponseDto<Job> add(User user) { ... } I can POST the object like this with APACHE HTTP CLIENT: HttpPost post = new HttpPost(url); List nameValuePairs = new ArrayList(); nameValuePairs.add(new BasicNameValuePair("name", "xxx")); post.setEntity(new UrlEncodedFormEntity(nameValuePairs)); HttpResponse response = client.execute(post); In controller I get user

How to POST JSON object to spring controller?

梦想的初衷 提交于 2020-01-05 23:21:08
问题 I have spring controller: @RequestMapping(value = "/add", method = RequestMethod.POST, consumes = "application/json") public @ResponseBody ResponseDto<Job> add(User user) { ... } I can POST the object like this with APACHE HTTP CLIENT: HttpPost post = new HttpPost(url); List nameValuePairs = new ArrayList(); nameValuePairs.add(new BasicNameValuePair("name", "xxx")); post.setEntity(new UrlEncodedFormEntity(nameValuePairs)); HttpResponse response = client.execute(post); In controller I get user

Convert Curl command into Java/Android

为君一笑 提交于 2020-01-05 14:04:07
问题 I am developing two applications - First one is web application using Spring MVC 3 And the second one is an Android application for same web application. In both, I am integrating basic authentication to authenticate user on that site using the APIs. In the API tutorial, following curl command is given to authenticate user - $ curl -u username:password insert_Url_here -d '[xml body here]' I am not getting, how to convert this command in Java and android code. Please guide me. I am totally

Bypass DNS lookup and submit URL to proxy

我只是一个虾纸丫 提交于 2020-01-05 10:17:23
问题 I have Java application that uses Apache HttpComponents to make web request. I have configured the application to use Proxy Servers using the JVM Property java -Dhttp.proxyHost=127.0.0.1 -Dhttp.proxyPort=3132 Currently my java application client makes DNS lookup in which it will fail. I want the Proxy to do the DNS resolution just like how web browsers do in automatic Proxy configuration mode (with .pac files). 回答1: Try looking here: http://hc.apache.org/httpcomponents-client-ga/httpclient

Java 8 update 161 breaks HTTPClient Kerberos authentication

心已入冬 提交于 2020-01-05 08:09:50
问题 My HTTPClient Kerberos authentication set up is similar to this one. My login.conf looks like this: com.sun.security.jgss.login { com.sun.security.auth.module.Krb5LoginModule required useTicketCache=true useKeyTab=true storeKey=true keyTab=<keytab> principal=<principal>; }; com.sun.security.jgss.initiate { com.sun.security.auth.module.Krb5LoginModule required useTicketCache=true useKeyTab=true storeKey=true keyTab=<principal> principal=<keytab>; }; com.sun.security.jgss.accept { com.sun

Java 8 update 161 breaks HTTPClient Kerberos authentication

穿精又带淫゛_ 提交于 2020-01-05 08:09:13
问题 My HTTPClient Kerberos authentication set up is similar to this one. My login.conf looks like this: com.sun.security.jgss.login { com.sun.security.auth.module.Krb5LoginModule required useTicketCache=true useKeyTab=true storeKey=true keyTab=<keytab> principal=<principal>; }; com.sun.security.jgss.initiate { com.sun.security.auth.module.Krb5LoginModule required useTicketCache=true useKeyTab=true storeKey=true keyTab=<principal> principal=<keytab>; }; com.sun.security.jgss.accept { com.sun

Fetching Json from firebase as string not working in java

给你一囗甜甜゛ 提交于 2020-01-05 04:24:07
问题 Firebase data using rest: FireBase data in console: Java code to fetch data from firebase PoolingHttpClientConnectionManager cm = new PoolingHttpClientConnectionManager(); cm.setMaxTotal(100); cm.setDefaultMaxPerRoute(100); httpClient = HttpClients.custom() .setConnectionManager(cm) .build(); CloseableHttpResponse response; try { String url = "https://testcustom-a1a4d.firebaseio.com/1719126/1719130/1719121.json?auth=myauthId"; HttpGet httpGet = new HttpGet(url); response = httpClient.execute

Jersey Http Client replying with 411 on POST request

蓝咒 提交于 2020-01-05 04:07:32
问题 I'm using Jersey HTTP Client for sending POST request and receiving 411 Content Length missing in response. However this error is not thrown in all the cases. There are some calls where I'm using json content type and it is working fine. For this particular request where I'm sending the request to a specific URL I'm receiving 411 Content Length required. While with the same payload when I'm using a different URL it is working fine. This is how I'm setting Form Entity in Jersey Client Request