I have been spending hours on this and can't figure out why. I am even using parts of the code example used on the bls.gov website. I shouldn't have any issues because it's a public API... Please help!
public static void main(String[] args) throws ClientProtocolException, IOException {
HttpHost proxy = new HttpHost("myproxy.com", 3128, "http");
CloseableHttpClient httpClient = HttpClientBuilder.create().setProxy(proxy).build(); // Use
// this
// instead
HttpPost request = new HttpPost("https://api.bls.gov/publicAPI/v1/timeseries/data/");
StringEntity params = new StringEntity("{\"seriesid\":[\"LAUCN040010000000005\", \"LAUCN040010000000006\"]}");
request.setEntity(params);
request.setHeader("Accept", "application/json");
request.setHeader("Content-type", "application/json");
CloseableHttpResponse response = httpClient.execute(request);
System.out.println("HERE");
System.out.println(response.getStatusLine());
response.close();
Keep getting this error:
Exception in thread "main" javax.net.ssl.SSLHandshakeException: sun.security.validator.ValidatorException: PKIX path building failed: sun.security.provider.certpath.SunCertPathBuilderException: unable to find valid certification path to requested target
at sun.security.ssl.Alerts.getSSLException(Unknown Source)
at sun.security.ssl.SSLSocketImpl.fatal(Unknown Source)
at sun.security.ssl.Handshaker.fatalSE(Unknown Source)
at sun.security.ssl.Handshaker.fatalSE(Unknown Source)
at sun.security.ssl.ClientHandshaker.serverCertificate(Unknown Source)
at sun.security.ssl.ClientHandshaker.processMessage(Unknown Source)
at sun.security.ssl.Handshaker.processLoop(Unknown Source)
at sun.security.ssl.Handshaker.process_record(Unknown Source)
at sun.security.ssl.SSLSocketImpl.readRecord(Unknown Source)
at sun.security.ssl.SSLSocketImpl.performInitialHandshake(Unknown Source)