Java getInputStream 400 errors
- by Bill Szerdy
When I contact a web service using a Java HttpUrlConnection it just returns a 400 Bad Request (IOException). How do I get the XML information that the server is returning; it does not appear to be in the getErrorStream of the connection nor is it in any of the exception information.
When I run the following PHP code against a web service:
<?php
$ch = curl_init();
curl_setopt($ch, CURLOPT_URL, "https://www.myclientaddress.com/here/" );
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1 );
curl_setopt($ch, CURLOPT_POST,1 );
curl_setopt($ch, CURLOPT_POSTFIELDS,"username=ted&password=scheckler&type=consumer&id=123456789&zip=12345");
$result=curl_exec ($ch);
echo $result;
?>
it returns the following:
<?xml version="1.0" encoding="utf-8"?>
<response>
<status>failure</status>
<errors>
<error name="RES_ZIP">Zip code is not valid.</error>
<error name="ZIP">Invalid zip code for residence address.</error>
</errors>
</response>
so I know the information exists