Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > comp.lang.java.programmer > #39397

Re: cross post. How do I get the http POST body?

From Arne Vajhøj <arne@vajhoej.dk>
Newsgroups comp.lang.java.programmer
Subject Re: cross post. How do I get the http POST body?
Date 2020-03-16 11:13 -0400
Organization Aioe.org NNTP Server
Message-ID <r4o525$av0$1@gioia.aioe.org> (permalink)
References <16110cea-bf84-4823-ae22-adf692a1f499@googlegroups.com>

Show all headers | View raw


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
> 
> HTTP/1.1 200 OK
> Cache-Control: no-cache, no-store, must-revalidate
> Pragma: no-cache
> Content-Type: application/json
> Expires: -1
> Vary: Accept-Encoding
> Server: Microsoft-IIS/10.0
> x-frame-options: DENY
> Date: Mon, 16 Mar 2020 14:30:03 GMT
> Content-Length: 1034
> Strict-Transport-Security: max-age=31536000
> X-CDN: Incapsula
> X-Iinfo: 9-31663561-31663518 PNNy RT(1584369003228 523) q(0 0 0 -1) r(3 3) U6
> 
> {"SecuredPropertiesKey":"00000000-0000-0000-0000-000000000000","Success":true,"ErrorMessage":null,"Errors":[],"Warnings":[],"Informationals":[],"Result":{"EmployeeBalanceErrors":null,"EmployeeId":9414,"ExpiringTransactions":[],"Header":["Type","Accrued","Approved","Pending","Remaining","Exceeded","Unit"],"Totals":[{"BalanceId":3,"BalanceName":"PTO","UnitName":"Hours","BalancePeriodEnd":null,"BalancePeriodStart":"2020-01-01T00:00:00","Columns":[{"Header":"Type","Display":"PTO","Value":"PTO","ColumnType":1},{"Header":"Accrued","Display":"17.43737","Value":17.43737,"ColumnType":7},{"Header":"Approved","Display":"-3.50000","Value":-3.50000,"ColumnType":7},{"Header":"Pending","Display":"0.00000","Value":0.0,"ColumnType":7},{"Header":"Remaining","Display":"13.93737","Value":13.93737,"ColumnType":7},{"Header":"Exceeded","Display":"0.00000","Value":0.0,"ColumnType":7},{"Header":"Unit","Display":"Hours","Value":"Hours","ColumnType":6}],"IsGrantBased":false,"IsAccessRestricted":false,"SortOrder":-2147483648}],"Transactions":[]}}

 >   private String downloadLoginPage(URL url) throws IOException {

>              connection = (HttpURLConnection) url.openConnection();

>              connection.setDoInput(true);
>              connection.setRequestMethod("POST");
>              connection.setRequestProperty("Content-Type",
>                      "application/x-www-form-urlencoded");

>              connection.connect();

>              inputStream = connection.getInputStream();

>              if (inputStream != null) {
>                  result = readStream(inputStream, 64000); //Lame way to emulate ping.
>              }

> 03-16 07:21:15.415 5938-5970/com.example.cd.workreminder E/LG_WORK_WEB:: THE RESPONSE MESSAGE IS:
>      <!DOCTYPE html>
>      <html>
>      <head><meta charset="utf-8" /><meta http-equiv="X-UA-Compatible" content="IE=10; IE=9; IE=8; IE=EDGE" /><meta name="viewport" content="width=device-width, initial-scale=1" /><title>
>              Dayforce
>      </title><link rel="shortcut icon" href="Content/Common/images/favicon.ico" /><link rel="apple-touch-icon" sizes="180x180" href="Content/Common/images/apple-touch-icon.png" /><link rel="mask-icon" href="Content/Common/images/safari-pinned-tab.svg" color="#3067db" /><link rel="manifest" href="Content/Common/images/manifest.webmanifest" /><meta name="theme-color" content="#ffffff" /><meta name="msapplication-square70x70logo" content="Content/Common/images/mstile-70x70.png" /><meta name="msapplication-square150x150logo" content="Content/Common/images/mstile-150x150.png" /><meta name="msapplication-wide310x150logo" content="Content/Common/images/mstile-310x150.png" /><meta name="msapplication-square310x310logo" content="Content/Common/images/mstile-310x310.png" /><meta name="msapplication-TileColor" content="#ffffff" /><link id="styles" rel="stylesheet" href="/MyDayforce/Content/Common/styles/rebrandedCss?v=nwLz1BN8ZUfRwzR_Cq1k8qgVoiBwHNkZkQYcDHpSaok1" />
>      <script type="text/javascript" src="https://static.dayforcehcm.comlibraries/jquery/3.4.1/jquery.min.js"></script><script type="text/javascript" src="/MyDayforce/Scripts/Libs/bootstrap-modal.js"></script></head>
>      <body>
> 
>   <form method="post" action="./MyDayforce.aspx" id="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ry2aNMfGVDu+T72qB78jiLt/BmQDBydLw4MmP9goAqt3h1qhseICdfON8cK7ZcMKDSdM8zsTEAbTTb3g1Ueo7b4H7Yd0zXhT39I+iC6fg06cA9o/gJYe1QmYCiNvew6nNOc+XgvKDkHAvYCTEnV+fvVa+rhWakI6MfpajrBOObPY5nEFq2pPeRzekFmWVXktP0z1Pc8l/osGrGTWPIcddw/Ktwjn+0ZOa4MT/F98VKJtOUbtMwXha2AdryqMjqH8jbbt873C/RHmbLxJO/8pshLRN99R4pbQ7TnDaOB1VG+xB07DSJU6cDH8/RFFG5gnkgUlI3MrMCnaJGsnQbtXiPLoukzCNPiVugEczp2iL7zW7
> 03-16 07:23:27.791 5938-5970/com.example.cd.workreminder E/LG_WORK_WEB:: THE RESPONSE MESSAGE IS:

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?

Web service call should be pretty straight forward.

Login is usually also simple, but not for ASP.NET web forms, which
it looks like you are trying to access.

Arne

Back to comp.lang.java.programmer | Previous | Next — Previous in thread | Next in thread | Find similar | Unroll thread


Thread

cross post. How do I get the http POST body? "C.D. Altenburg, Ph.D," <cdalten@gmail.com> - 2020-03-16 07:47 -0700
  Re: cross post. How do I get the http POST body? Arne Vajhøj <arne@vajhoej.dk> - 2020-03-16 11:13 -0400
    Re: cross post. How do I get the http POST body? "C.D. Altenburg, Ph.D," <cdalten@gmail.com> - 2020-03-17 04:52 -0700
      Re: cross post. How do I get the http POST body? Arne Vajhøj <arne@vajhoej.dk> - 2020-03-17 10:05 -0400
      Re: cross post. How do I get the http POST body? Joerg Meier <joergmmeier@arcor.de> - 2020-03-17 15:11 +0100

csiph-web