Java URL class request receives status code 400 for valid URL request
posted 9 years ago
Through my Java program (which uses URL class) I am trying to access USPS RateCalculator service to obtain shipping rate for a given mail package with given specifications (embeded in my XML request like weight, length, height...etc.)
USPS expects the whole request to be sent as XML and in return, it sends shipping rate in the form of XML as response.
When I run my Java program from command line, I get response 400 from USPS server. Before making request to USPS, I print the entire request on screen. If I cut and paste this printed request in the browser, I get proper XML response back.
Also, to make sure that my Java program is working properly, when I replace the URL- i.e. 'myurl' in my code with 'http://www.yahoo.com', I get propper response with complete HTML. So code is working fine.
Offcourse browser and command line through which I am running my java program are on the same computer and hence same network.
This behaviour is really puzzling........any ideas?