Path: csiph.com!aioe.org!.POSTED.O5hsyUvK01te0L/SZurVSQ.user.gioia.aioe.org!not-for-mail From: =?UTF-8?Q?Arne_Vajh=c3=b8j?= Newsgroups: comp.lang.java.programmer Subject: Re: cross post. How do I get the http POST body? Date: Tue, 17 Mar 2020 10:05:48 -0400 Organization: Aioe.org NNTP Server Lines: 35 Message-ID: References: <16110cea-bf84-4823-ae22-adf692a1f499@googlegroups.com> NNTP-Posting-Host: O5hsyUvK01te0L/SZurVSQ.user.gioia.aioe.org Mime-Version: 1.0 Content-Type: text/plain; charset=utf-8; format=flowed Content-Transfer-Encoding: 8bit X-Complaints-To: abuse@aioe.org User-Agent: Mozilla/5.0 (Windows NT 6.1; WOW64; rv:68.0) Gecko/20100101 Thunderbird/68.6.0 X-Notice: Filtered by postfilter v. 0.9.2 Content-Language: en-US Xref: csiph.com comp.lang.java.programmer:39399 On 3/17/2020 7:52 AM, C.D. Altenburg, Ph.D, wrote: > On Monday, March 16, 2020 at 8:13:22 AM UTC-7, Arne Vajhøj wrote: >> On 3/16/2020 10:47 AM, C.D. Altenburg, Ph.D, wrote: >>> The question is how do I get the post body in Java. Ie, the http body has the following format >> The basic usage of HttpURLConnection. >> >> Most people prefer to use Apache HttpClient (or if you are at >> Java 11 then the new builtin HttpClient). >> >> But all the above seems a bit mixed up. >> >> It seem like: >> * you want to call a web service and get some JSON data back >> * you actually call a login page >> >> What do you want to do? >> > I just want to call a web service and get some JSON data back. And I don't use HttpClient because it's not supported on the Java platform that I use. Apache HttpClient is just a jar file - it should work on any Java compliant platform. If you are developing for Android it may be a bit messier - Android ship with an old version of Apache HttpClient, but you can add a special Android version of newer version if you need to. But HttpUrlConnection should also be able to do the job. You set method to POST you write request body to getOutputStream() and you read response body from getInputStream(). Arne