Cant download ethereum Events with web3j - java

When i try download Events from blockhain:
<!-- language: lang-js -->
Web3j web3 = Web3j.build(new HttpService("https://rinkeby.infura.io/naqTNN4B2QavbM4vZI3q"));
Credentials credentials =Credentials.create("94b5486c4657faf6d3834c2efd70d90a3cc746db101de32b997206e0ddb5234e");
TenderFactory factory = TenderFactory.load("0x16606f347cf1b36c08690b150b96dba2031d6729", web3, credentials, GAS_PRICE, GAS_LIMIT);
final Event event = new Event("NewContract",
Arrays.<TypeReference<?>>asList(new TypeReference<Utf8String>() {
}),
Arrays.<TypeReference<?>>asList(new TypeReference<Utf8String>() {
}));
EthFilter filter = new EthFilter(DefaultBlockParameterName.EARLIEST,
DefaultBlockParameterName.EARLIEST, factory.getContractAddress());
filter.addSingleTopic(EventEncoder.encode(event));
Toolkit.getDefaultToolkit().beep();
web3.ethLogObservable(filter).subscribe(log -> {
LOG.info("log.getTopics=" + log.getTopics());
});
I got exeption:
17:43:05.719 [main] INFO r.s.tenderchain.Download - contractAddress = 0x16606f347cf1b36c08690b150b96dba2031d6729
17:43:07.097 [main] DEBUG org.web3j.protocol.http.HttpService - --> POST https://rinkeby.infura.io/naqTNN4B2QavbM4vZI3q http/1.1
17:43:07.098 [main] DEBUG org.web3j.protocol.http.HttpService - Content-Type: application/json; charset=utf-8
17:43:07.098 [main] DEBUG org.web3j.protocol.http.HttpService - Content-Length: 243
17:43:07.102 [main] DEBUG org.web3j.protocol.http.HttpService -
17:43:07.103 [main] DEBUG org.web3j.protocol.http.HttpService - {"jsonrpc":"2.0","method":"eth_newFilter","params":[{"topics":["0xa291e5980c03d23637198189ac50f67cecef9d808328c0420a23fa32fc16084a"],"fromBlock":"earliest","toBlock":"earliest","address":["0x16606f347cf1b36c08690b150b96dba2031d6729"]}],"id":0}
17:43:07.104 [main] DEBUG org.web3j.protocol.http.HttpService - --> END POST (243-byte body)
17:43:08.688 [main] DEBUG org.web3j.protocol.http.HttpService - <-- 405 Method Not Allowed https://rinkeby.infura.io/naqTNN4B2QavbM4vZI3q (1582ms)
17:43:08.689 [main] DEBUG org.web3j.protocol.http.HttpService - Date: Wed, 20 Dec 2017 14:43:08 GMT
17:43:08.694 [main] DEBUG org.web3j.protocol.http.HttpService - Content-Type: text/plain; charset=utf-8
17:43:08.694 [main] DEBUG org.web3j.protocol.http.HttpService - Content-Length: 0
17:43:08.694 [main] DEBUG org.web3j.protocol.http.HttpService - Connection: keep-alive
17:43:08.694 [main] DEBUG org.web3j.protocol.http.HttpService - Server: nginx/1.10.3 (Ubuntu)
17:43:08.695 [main] DEBUG org.web3j.protocol.http.HttpService - Vary: Origin
17:43:08.698 [main] DEBUG org.web3j.protocol.http.HttpService - <-- END HTTP (0-byte body)
Exception in thread "main" rx.exceptions.OnErrorNotImplementedException: Invalid response received: okhttp3.internal.http.RealResponseBody#437e951d
at rx.internal.util.InternalObservableUtils$ErrorNotImplementedAction.call(InternalObservableUtils.java:386)
at rx.internal.util.InternalObservableUtils$ErrorNotImplementedAction.call(InternalObservableUtils.java:383)
at rx.internal.util.ActionSubscriber.onError(ActionSubscriber.java:44)
at rx.observers.SafeSubscriber._onError(SafeSubscriber.java:153)
at rx.observers.SafeSubscriber.onError(SafeSubscriber.java:115)
at rx.Observable.subscribe(Observable.java:10249)
at rx.Observable.subscribe(Observable.java:10205)
at rx.Observable.subscribe(Observable.java:10010)
at ru.simplex_software.tenderchain.Download.main(Download.java:82)
Caused by: org.web3j.protocol.exceptions.ClientConnectionException: Invalid response received: okhttp3.internal.http.RealResponseBody#437e951d
at org.web3j.protocol.http.HttpService.performIO(HttpService.java:116)
at org.web3j.protocol.Service.send(Service.java:31)
at org.web3j.protocol.core.Request.send(Request.java:71)
at org.web3j.protocol.core.filters.LogFilter.sendRequest(LogFilter.java:31)
at org.web3j.protocol.core.filters.Filter.run(Filter.java:40)
....
org.web3j.protocol.rx.JsonRpc2_0Rx.lambda$ethLogObservable$10(JsonRpc2_0Rx.java:65)
at rx.Observable.subscribe(Observable.java:10238)
... 3 more
How to fix this and download NewContract events?

infura supports websocket endpoints on mainnet, ropsten and rinkeby now that allow you to listen to events. However, web3j doesn't support until now websockets so you can't use filters in web3 while connected to infura.

Related

Read time out in Apache HTTP Client but request runs fine with curl

I have a PUT requests that is done by a dependency scanner we are using
I'm behind a corporate proxy
Request is done with Apache HTTP Client 4
I get a "read time out" after the configured timeout
I recreated the request with curl and this works fine (with the same proxy) and finishes within seconds
It works fine with Apache HTTP Client without the proxy.
So I'm trying to find out what config is missing in the HTTP client config or what else could be the error. Unfortunately neither our networking team nor the product vendor could help me out :-(
This is the curl request:
curl --connect-timeout 60 -m 60 -v -X PUT --data-binary #test.json
https://someblackduckserver/api/developer-scans/12345
-H "Content-type: application/vnd.blackducksoftware.developer-scan-1-ld-2+json"
-H "X-BD-DOCUMENT-COUNT: 1"
-H "Accept: application/vnd.blackducksoftware.scan-4+json"
-H "X-BD-MODE: append"
-H "X-BD-RAPID-SCAN-MODE: ALL" -H "X-BD-VERSION-NAME: scan-test"
-H "User-Agent: synopsys_detect/8.1.0-SNAPSHOT BlackDuckCommon/65.0.0 ..."
-H "X-BD-PROJECT-NAME: scan-test"
-H "Authorization: Bearer ..... left out ....."
Where test.json is a json file with about 1.3MB.
Minified code when using Apache HTTP Client:
RequestBuilder requestBuilder = RequestBuilder.create("PUT");
URIBuilder uriBuilder = new URIBuilder(new URI("https://someblackduckserver/api/developer-scans/12345"));
requestBuilder.setUri(uriBuilder.build());
Charset bodyEncoding = StandardCharsets.UTF_8;
requestBuilder.setCharset(bodyEncoding);
requestBuilder.addHeader("Content-type", "application/vnd.blackducksoftware.developer-scan-1-ld-2+json");
requestBuilder.addHeader("X-BD-DOCUMENT-COUNT", "1");
requestBuilder.addHeader("Accept", "application/vnd.blackducksoftware.scan-4+json");
requestBuilder.addHeader("X-BD-MODE", "append");
requestBuilder.addHeader("X-BD-RAPID-SCAN-MODE", "ALL");
requestBuilder.addHeader("X-BD-VERSION-NAME", "scan-test");
requestBuilder.addHeader("User-Agent", "synopsys_detect/8.1.0-SNAPSHOT BlackDuckCommon/65.0.0 ...");
requestBuilder.addHeader("X-BD-PROJECT-NAME", "scan-test");
requestBuilder.addHeader("Authorization", "Bearer ..... left out .....");
HttpEntity httpEntity = new FileEntity(new File("test.json"));
requestBuilder.setEntity(httpEntity);
HttpUriRequest request = requestBuilder.build();
HttpContext httpContext = new BasicHttpContext();
HttpClientBuilder clientBuilder = HttpClientBuilder.create();
RequestConfig.Builder defaultRequestConfigBuilder = RequestConfig.custom().setCookieSpec(CookieSpecs.STANDARD);
// set our proxy
defaultRequestConfigBuilder.setProxy(new HttpHost("..... (left out)", 8080));
// set timeout
int timeoutInSeconds = 60;
defaultRequestConfigBuilder.setConnectTimeout(timeoutInSeconds * 1000);
defaultRequestConfigBuilder.setSocketTimeout(timeoutInSeconds * 1000);
defaultRequestConfigBuilder.setConnectionRequestTimeout(timeoutInSeconds * 1000);
clientBuilder.setDefaultRequestConfig(defaultRequestConfigBuilder.build());
// for testing: ignore ssl
HostnameVerifier hostnameVerifier;
SSLContext sslContext = SSLContextBuilder.create().loadTrustMaterial(new TrustAllStrategy()).build();
hostnameVerifier = new NoopHostnameVerifier();
SSLConnectionSocketFactory connectionFactory = new SSLConnectionSocketFactory(sslContext, hostnameVerifier);
clientBuilder.setSSLSocketFactory(connectionFactory);
try (CloseableHttpClient client = clientBuilder.build()) {
CloseableHttpResponse closeableHttpResponse = client.execute(request, httpContext);
System.out.println(closeableHttpResponse);
}
I removed some sensitive details from the request.
Any idea what I'm missing here or what could go wrong?
Logs from a sample the call:
2022-07-25 10:38:38.201 [main] DEBUG o.a.h.c.protocol.RequestAddCookies - CookieSpec selected: default
2022-07-25 10:38:38.206 [main] DEBUG o.a.h.c.protocol.RequestAuthCache - Auth cache not set in the context
2022-07-25 10:38:38.207 [main] DEBUG o.a.h.i.c.PoolingHttpClientConnectionManager - Connection request: [route: {tls}->http://our.proxy.ip.address:8080->https://someblackduckserver.com:443][total available: 0; route allocated: 0 of 2; total allocated: 0 of 20]
2022-07-25 10:38:38.259 [main] DEBUG o.a.h.i.c.PoolingHttpClientConnectionManager - Connection leased: [id: 0][route: {tls}->http://our.proxy.ip.address:8080->https://someblackduckserver.com:443][total available: 0; route allocated: 1 of 2; total allocated: 1 of 20]
2022-07-25 10:38:38.260 [main] DEBUG o.a.h.impl.execchain.MainClientExec - Opening connection {tls}->http://our.proxy.ip.address:8080->https://someblackduckserver.com:443
2022-07-25 10:38:38.261 [main] DEBUG o.a.h.i.c.DefaultHttpClientConnectionOperator - Connecting to /our.proxy.ip.address:8080
2022-07-25 10:38:38.301 [main] DEBUG o.a.h.i.c.DefaultHttpClientConnectionOperator - Connection established 10.17.10.44:34272<->our.proxy.ip.address:8080
2022-07-25 10:38:38.317 [main] DEBUG org.apache.http.headers - http-outgoing-0 >> CONNECT someblackduckserver.com:443 HTTP/1.1
2022-07-25 10:38:38.317 [main] DEBUG org.apache.http.headers - http-outgoing-0 >> Host: someblackduckserver.com
2022-07-25 10:38:38.317 [main] DEBUG org.apache.http.headers - http-outgoing-0 >> User-Agent: Apache-HttpClient/4.5.13 (Java/11.0.13)
2022-07-25 10:38:38.317 [main] DEBUG org.apache.http.wire - http-outgoing-0 >> "CONNECT someblackduckserver.com:443 HTTP/1.1[\r][\n]"
2022-07-25 10:38:38.317 [main] DEBUG org.apache.http.wire - http-outgoing-0 >> "Host: someblackduckserver.com[\r][\n]"
2022-07-25 10:38:38.317 [main] DEBUG org.apache.http.wire - http-outgoing-0 >> "User-Agent: Apache-HttpClient/4.5.13 (Java/11.0.13)[\r][\n]"
2022-07-25 10:38:38.317 [main] DEBUG org.apache.http.wire - http-outgoing-0 >> "[\r][\n]"
2022-07-25 10:38:38.346 [main] DEBUG org.apache.http.wire - http-outgoing-0 << "HTTP/1.1 200 Connection established[\r][\n]"
2022-07-25 10:38:38.346 [main] DEBUG org.apache.http.wire - http-outgoing-0 << "Proxy-Agent: Proxy-Vendor-Proxy/1.0[\r][\n]"
2022-07-25 10:38:38.346 [main] DEBUG org.apache.http.wire - http-outgoing-0 << "[\r][\n]"
2022-07-25 10:38:38.347 [main] DEBUG org.apache.http.headers - http-outgoing-0 << HTTP/1.1 200 Connection established
2022-07-25 10:38:38.347 [main] DEBUG org.apache.http.headers - http-outgoing-0 << Proxy-Agent: Proxy-Vendor-Proxy/1.0
2022-07-25 10:38:38.347 [main] DEBUG o.a.h.impl.execchain.MainClientExec - Tunnel to target created.
2022-07-25 10:38:38.432 [main] DEBUG o.a.h.c.s.SSLConnectionSocketFactory - Enabled protocols: [TLSv1.3, TLSv1.2]
2022-07-25 10:38:38.440 [main] DEBUG o.a.h.c.s.SSLConnectionSocketFactory - Enabled cipher suites:[TLS_AES_256_GCM_SHA384, TLS_AES_128_GCM_SHA256, TLS_ECDHE_ECDSA_WITH_AES_256_GCM_SHA384, TLS_ECDHE_ECDSA_WITH_AES_128_GCM_SHA256, TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384, TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256, TLS_DHE_RSA_WITH_AES_256_GCM_SHA384, TLS_DHE_DSS_WITH_AES_256_GCM_SHA384, TLS_DHE_RSA_WITH_AES_128_GCM_SHA256, TLS_DHE_DSS_WITH_AES_128_GCM_SHA256, TLS_ECDHE_ECDSA_WITH_AES_256_CBC_SHA384, TLS_ECDHE_RSA_WITH_AES_256_CBC_SHA384, TLS_ECDHE_ECDSA_WITH_AES_128_CBC_SHA256, TLS_ECDHE_RSA_WITH_AES_128_CBC_SHA256, TLS_DHE_RSA_WITH_AES_256_CBC_SHA256, TLS_DHE_DSS_WITH_AES_256_CBC_SHA256, TLS_DHE_RSA_WITH_AES_128_CBC_SHA256, TLS_DHE_DSS_WITH_AES_128_CBC_SHA256, TLS_ECDH_ECDSA_WITH_AES_256_GCM_SHA384, TLS_ECDH_RSA_WITH_AES_256_GCM_SHA384, TLS_ECDH_ECDSA_WITH_AES_128_GCM_SHA256, TLS_ECDH_RSA_WITH_AES_128_GCM_SHA256, TLS_ECDH_ECDSA_WITH_AES_256_CBC_SHA384, TLS_ECDH_RSA_WITH_AES_256_CBC_SHA384, TLS_ECDH_ECDSA_WITH_AES_128_CBC_SHA256, TLS_ECDH_RSA_WITH_AES_128_CBC_SHA256, TLS_ECDHE_ECDSA_WITH_AES_256_CBC_SHA, TLS_ECDHE_RSA_WITH_AES_256_CBC_SHA, TLS_ECDHE_ECDSA_WITH_AES_128_CBC_SHA, TLS_ECDHE_RSA_WITH_AES_128_CBC_SHA, TLS_DHE_RSA_WITH_AES_256_CBC_SHA, TLS_DHE_DSS_WITH_AES_256_CBC_SHA, TLS_DHE_RSA_WITH_AES_128_CBC_SHA, TLS_DHE_DSS_WITH_AES_128_CBC_SHA, TLS_ECDH_ECDSA_WITH_AES_256_CBC_SHA, TLS_ECDH_RSA_WITH_AES_256_CBC_SHA, TLS_ECDH_ECDSA_WITH_AES_128_CBC_SHA, TLS_ECDH_RSA_WITH_AES_128_CBC_SHA, TLS_RSA_WITH_AES_256_GCM_SHA384, TLS_RSA_WITH_AES_128_GCM_SHA256, TLS_RSA_WITH_AES_256_CBC_SHA256, TLS_RSA_WITH_AES_128_CBC_SHA256, TLS_RSA_WITH_AES_256_CBC_SHA, TLS_RSA_WITH_AES_128_CBC_SHA, TLS_EMPTY_RENEGOTIATION_INFO_SCSV]
2022-07-25 10:38:38.440 [main] DEBUG o.a.h.c.s.SSLConnectionSocketFactory - Starting handshake
2022-07-25 10:38:39.252 [main] DEBUG jdk.event.security - X509Certificate: ... our ssl inspect certificate ...
2022-07-25 10:38:39.252 [main] DEBUG jdk.event.security - X509Certificate: ... our internal certificate ...
2022-07-25 10:38:39.275 [main] DEBUG jdk.event.security - TLSHandshake: someblackduckserver.com:8080, TLSv1.2, TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256, 1942523025
2022-07-25 10:38:39.276 [main] DEBUG o.a.h.c.s.SSLConnectionSocketFactory - Secure session established
2022-07-25 10:38:39.276 [main] DEBUG o.a.h.c.s.SSLConnectionSocketFactory - negotiated protocol: TLSv1.2
2022-07-25 10:38:39.276 [main] DEBUG o.a.h.c.s.SSLConnectionSocketFactory - negotiated cipher suite: TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256
2022-07-25 10:38:39.276 [main] DEBUG o.a.h.c.s.SSLConnectionSocketFactory - peer principal: CN=*.someblackduckserver.com, O="Synopsys, Inc.", L=Mountain View, ST=California, C=US
2022-07-25 10:38:39.276 [main] DEBUG o.a.h.c.s.SSLConnectionSocketFactory - peer alternative names: [*.someblackduckserver.com]
2022-07-25 10:38:39.276 [main] DEBUG o.a.h.c.s.SSLConnectionSocketFactory - issuer principal: ... our ssl inspect certificate ...
2022-07-25 10:38:39.276 [main] DEBUG o.a.h.i.c.DefaultManagedHttpClientConnection - http-outgoing-0: set socket timeout to 60000
2022-07-25 10:38:39.277 [main] DEBUG o.a.h.impl.execchain.MainClientExec - Executing request PUT /api/developer-scans/12345 HTTP/1.1
2022-07-25 10:38:39.277 [main] DEBUG org.apache.http.headers - http-outgoing-0 >> PUT /api/developer-scans/12345 HTTP/1.1
2022-07-25 10:38:39.277 [main] DEBUG org.apache.http.headers - http-outgoing-0 >> Content-type: application/vnd.blackducksoftware.developer-scan-1-ld-2+json
2022-07-25 10:38:39.277 [main] DEBUG org.apache.http.headers - http-outgoing-0 >> X-BD-DOCUMENT-COUNT: 1
2022-07-25 10:38:39.277 [main] DEBUG org.apache.http.headers - http-outgoing-0 >> Accept: application/vnd.blackducksoftware.scan-4+json
2022-07-25 10:38:39.277 [main] DEBUG org.apache.http.headers - http-outgoing-0 >> X-BD-MODE: append
2022-07-25 10:38:39.277 [main] DEBUG org.apache.http.headers - http-outgoing-0 >> X-BD-RAPID-SCAN-MODE: ALL
2022-07-25 10:38:39.277 [main] DEBUG org.apache.http.headers - http-outgoing-0 >> X-BD-VERSION-NAME: rapid-scan-test-igl-2
2022-07-25 10:38:39.277 [main] DEBUG org.apache.http.headers - http-outgoing-0 >> User-Agent: synopsys_detect/8.1.0-SNAPSHOT BlackDuckCommon/65.0.0 (Eclipse Foundation 11.0.12 amd64 Windows 10 10.0)
2022-07-25 10:38:39.277 [main] DEBUG org.apache.http.headers - http-outgoing-0 >> X-BD-PROJECT-NAME: project_name
2022-07-25 10:38:39.278 [main] DEBUG org.apache.http.headers - http-outgoing-0 >> Authorization: Bearer ...
2022-07-25 10:38:39.278 [main] DEBUG org.apache.http.headers - http-outgoing-0 >> Content-Length: 287381
2022-07-25 10:38:39.278 [main] DEBUG org.apache.http.headers - http-outgoing-0 >> Host: someblackduckserver.com
2022-07-25 10:38:39.278 [main] DEBUG org.apache.http.headers - http-outgoing-0 >> Connection: Keep-Alive
2022-07-25 10:38:39.278 [main] DEBUG org.apache.http.headers - http-outgoing-0 >> Accept-Encoding: gzip,deflate
2022-07-25 10:38:39.278 [main] DEBUG org.apache.http.wire - http-outgoing-0 >> "PUT /api/developer-scans/12345 HTTP/1.1[\r][\n]"
2022-07-25 10:38:39.278 [main] DEBUG org.apache.http.wire - http-outgoing-0 >> "Content-type: application/vnd.blackducksoftware.developer-scan-1-ld-2+json[\r][\n]"
2022-07-25 10:38:39.278 [main] DEBUG org.apache.http.wire - http-outgoing-0 >> "X-BD-DOCUMENT-COUNT: 1[\r][\n]"
2022-07-25 10:38:39.279 [main] DEBUG org.apache.http.wire - http-outgoing-0 >> "Accept: application/vnd.blackducksoftware.scan-4+json[\r][\n]"
2022-07-25 10:38:39.279 [main] DEBUG org.apache.http.wire - http-outgoing-0 >> "X-BD-MODE: append[\r][\n]"
2022-07-25 10:38:39.279 [main] DEBUG org.apache.http.wire - http-outgoing-0 >> "X-BD-RAPID-SCAN-MODE: ALL[\r][\n]"
2022-07-25 10:38:39.279 [main] DEBUG org.apache.http.wire - http-outgoing-0 >> "X-BD-VERSION-NAME: rapid-scan-test-igl-2[\r][\n]"
2022-07-25 10:38:39.279 [main] DEBUG org.apache.http.wire - http-outgoing-0 >> "User-Agent: synopsys_detect/8.1.0-SNAPSHOT BlackDuckCommon/65.0.0 (Eclipse Foundation 11.0.12 amd64 Windows 10 10.0)[\r][\n]"
2022-07-25 10:38:39.279 [main] DEBUG org.apache.http.wire - http-outgoing-0 >> "X-BD-PROJECT-NAME: project_name[\r][\n]"
2022-07-25 10:38:39.279 [main] DEBUG org.apache.http.wire - http-outgoing-0 >> "Authorization: Bearer ...[\r][\n]"
2022-07-25 10:38:39.279 [main] DEBUG org.apache.http.wire - http-outgoing-0 >> "Content-Length: 287381[\r][\n]"
2022-07-25 10:38:39.279 [main] DEBUG org.apache.http.wire - http-outgoing-0 >> "Host: someblackduckserver.com[\r][\n]"
2022-07-25 10:38:39.279 [main] DEBUG org.apache.http.wire - http-outgoing-0 >> "Connection: Keep-Alive[\r][\n]"
2022-07-25 10:38:39.279 [main] DEBUG org.apache.http.wire - http-outgoing-0 >> "Accept-Encoding: gzip,deflate[\r][\n]"
2022-07-25 10:38:39.423 [main] DEBUG org.apache.http.wire - http-outgoing-0 >> .... all the logs for file content ....
2022-07-25 10:39:39.483 [main] DEBUG org.apache.http.wire - http-outgoing-0 << "[read] I/O error: Read timed out"
2022-07-25 10:39:39.483 [main] DEBUG o.a.h.i.c.DefaultManagedHttpClientConnection - http-outgoing-0: Close connection
2022-07-25 10:39:39.483 [main] DEBUG o.a.h.i.c.DefaultManagedHttpClientConnection - http-outgoing-0: Shutdown connection
2022-07-25 10:39:39.483 [main] DEBUG o.a.h.impl.execchain.MainClientExec - Connection discarded
2022-07-25 10:39:39.483 [main] DEBUG o.a.h.i.c.PoolingHttpClientConnectionManager - Connection released: [id: 0][route: {tls}->http://our.proxy.ip.address:8080->https://someblackduckserver.com:443][total available: 0; route allocated: 0 of 2; total allocated: 0 of 20]
2022-07-25 10:39:39.484 [main] DEBUG o.a.h.i.c.PoolingHttpClientConnectionManager - Connection manager is shutting down
2022-07-25 10:39:39.484 [main] DEBUG o.a.h.i.c.PoolingHttpClientConnectionManager - Connection manager shut down
Exception in thread "main" java.net.SocketTimeoutException: Read timed out
at java.base/java.net.SocketInputStream.socketRead0(Native Method)
at java.base/java.net.SocketInputStream.socketRead(SocketInputStream.java:115)
at java.base/java.net.SocketInputStream.read(SocketInputStream.java:168)
at java.base/java.net.SocketInputStream.read(SocketInputStream.java:140)
at java.base/sun.security.ssl.SSLSocketInputRecord.read(SSLSocketInputRecord.java:478)
at java.base/sun.security.ssl.SSLSocketInputRecord.readHeader(SSLSocketInputRecord.java:472)
at java.base/sun.security.ssl.SSLSocketInputRecord.bytesInCompletePacket(SSLSocketInputRecord.java:70)
at java.base/sun.security.ssl.SSLSocketImpl.readApplicationRecord(SSLSocketImpl.java:1318)
at java.base/sun.security.ssl.SSLSocketImpl$AppInputStream.read(SSLSocketImpl.java:959)
at org.apache.http.impl.conn.LoggingInputStream.read(LoggingInputStream.java:84)
at org.apache.http.impl.io.SessionInputBufferImpl.streamRead(SessionInputBufferImpl.java:137)
at org.apache.http.impl.io.SessionInputBufferImpl.fillBuffer(SessionInputBufferImpl.java:153)
at org.apache.http.impl.io.SessionInputBufferImpl.readLine(SessionInputBufferImpl.java:280)
at org.apache.http.impl.conn.DefaultHttpResponseParser.parseHead(DefaultHttpResponseParser.java:138)
at org.apache.http.impl.conn.DefaultHttpResponseParser.parseHead(DefaultHttpResponseParser.java:56)
at org.apache.http.impl.io.AbstractMessageParser.parse(AbstractMessageParser.java:259)
at org.apache.http.impl.DefaultBHttpClientConnection.receiveResponseHeader(DefaultBHttpClientConnection.java:163)
at org.apache.http.impl.conn.CPoolProxy.receiveResponseHeader(CPoolProxy.java:157)
at org.apache.http.protocol.HttpRequestExecutor.doReceiveResponse(HttpRequestExecutor.java:273)
at org.apache.http.protocol.HttpRequestExecutor.execute(HttpRequestExecutor.java:125)
at org.apache.http.impl.execchain.MainClientExec.execute(MainClientExec.java:272)
at org.apache.http.impl.execchain.ProtocolExec.execute(ProtocolExec.java:186)
at org.apache.http.impl.execchain.RetryExec.execute(RetryExec.java:89)
at org.apache.http.impl.execchain.RedirectExec.execute(RedirectExec.java:110)
at org.apache.http.impl.client.InternalHttpClient.doExecute(InternalHttpClient.java:185)
at org.apache.http.impl.client.CloseableHttpClient.execute(CloseableHttpClient.java:83)
at org.example.BdTest.main(BdTest.java:93)
May be not a solution but a workaround if it works. I wrote my own Http client that is much simpler than Apache Http client. The reason I wrote it is that in many cases you just need a simplistic functionality so using a thin library lessens complexity and allows you to debug it if need be and it would allow you easier way to get to the bottom of the problem. So, may be you can give it a shot. At may even work or if not than it would be much easier to debug than Apache Http client. My Http client is part of MgntUtils Open-Source library written and maintained by me. Here is HttpClient Javadoc. The library can be obtained as Maven artifact from Maven Central and from Github (including source code and Javadoc)

Apache HttpClient v5.0 doesn't authenticate with NTLM on Windows

I'm trying to make a request through a NTLM proxy like this:
try (CloseableHttpClient httpClient = WinHttpClients.createDefault()) {
HttpHost target = HttpHost.create("http://example.com");
HttpHost proxy = new HttpHost("http", "localhost", 80);
RequestConfig config = RequestConfig.custom().setProxy(proxy).build();
HttpGet request = new HttpGet("/");
request.setConfig(config);
try (CloseableHttpResponse response = httpClient.execute(target, request)) {
StatusLine statusLine = new StatusLine(response);
if (statusLine.getStatusCode() == HttpStatus.SC_OK) {
System.out.println("Test OK");
} else if (statusLine.getStatusCode() == HttpStatus.SC_PROXY_AUTHENTICATION_REQUIRED) {
throw new CredentialException(statusLine.getReasonPhrase());
}
}
} catch (Exception e) {
e.printStackTrace();
}
but it fails, here is the log:
[main] DEBUG org.apache.hc.client5.http.impl.classic.InternalHttpClient - ex-00000001: preparing request execution
[main] DEBUG org.apache.hc.client5.http.protocol.RequestAddCookies - Cookie spec selected: strict
[main] DEBUG org.apache.hc.client5.http.protocol.RequestAuthCache - Auth cache not set in the context
[main] DEBUG org.apache.hc.client5.http.impl.classic.ProtocolExec - ex-00000001: target auth state: UNCHALLENGED
[main] DEBUG org.apache.hc.client5.http.impl.classic.ProtocolExec - ex-00000001: proxy auth state: UNCHALLENGED
[main] DEBUG org.apache.hc.client5.http.impl.classic.ConnectExec - ex-00000001: acquiring connection with route {}->http://localhost:80->http://example.com:80
[main] DEBUG org.apache.hc.client5.http.impl.classic.InternalHttpClient - ex-00000001: acquiring endpoint (3 MINUTES)
[main] DEBUG org.apache.hc.client5.http.impl.io.PoolingHttpClientConnectionManager - ex-00000001: endpoint lease request (3 MINUTES) [route: {}->http://localhost:80->http://example.com:80][total available: 0; route allocated: 0 of 5; total allocated: 0 of 25]
[main] DEBUG org.apache.hc.client5.http.impl.io.PoolingHttpClientConnectionManager - ex-00000001: endpoint leased [route: {}->http://localhost:80->http://example.com:80][total available: 0; route allocated: 1 of 5; total allocated: 1 of 25]
[main] DEBUG org.apache.hc.client5.http.impl.io.PoolingHttpClientConnectionManager - ex-00000001: acquired ep-00000000
[main] DEBUG org.apache.hc.client5.http.impl.classic.InternalHttpClient - ex-00000001: acquired endpoint ep-00000000
[main] DEBUG org.apache.hc.client5.http.impl.classic.ConnectExec - ex-00000001: opening connection {}->http://localhost:80->http://example.com:80
[main] DEBUG org.apache.hc.client5.http.impl.classic.InternalHttpClient - ep-00000000: connecting endpoint (3 MINUTES)
[main] DEBUG org.apache.hc.client5.http.impl.io.PoolingHttpClientConnectionManager - ep-00000000: connecting endpoint to http://localhost:80 (3 MINUTES)
[main] DEBUG org.apache.hc.client5.http.impl.io.DefaultHttpClientConnectionOperator - http-outgoing-0: connecting to localhost/127.0.0.1:80
[main] DEBUG org.apache.hc.client5.http.impl.io.DefaultHttpClientConnectionOperator - http-outgoing-0: connection established 127.0.0.1:57194<->127.0.0.1:80
[main] DEBUG org.apache.hc.client5.http.impl.io.PoolingHttpClientConnectionManager - ep-00000000: connected http-outgoing-0
[main] DEBUG org.apache.hc.client5.http.impl.classic.InternalHttpClient - ep-00000000: endpoint connected
[main] DEBUG org.apache.hc.client5.http.impl.classic.MainClientExec - ex-00000001: executing GET http://example.com/ HTTP/1.1
[main] DEBUG org.apache.hc.client5.http.impl.classic.InternalHttpClient - ep-00000000: start execution ex-00000001
[main] DEBUG org.apache.hc.client5.http.impl.io.PoolingHttpClientConnectionManager - ep-00000000: executing exchange ex-00000001 over http-outgoing-0
[main] DEBUG org.apache.hc.client5.http.headers - http-outgoing-0 >> GET http://example.com/ HTTP/1.1
[main] DEBUG org.apache.hc.client5.http.headers - http-outgoing-0 >> Accept-Encoding: gzip, x-gzip, deflate
[main] DEBUG org.apache.hc.client5.http.headers - http-outgoing-0 >> Host: example.com
[main] DEBUG org.apache.hc.client5.http.headers - http-outgoing-0 >> User-Agent: Apache-HttpClient/5.0 (Java/1.8.0_222)
[main] DEBUG org.apache.hc.client5.http.wire - http-outgoing-0 >> "GET http://example.com/ HTTP/1.1[\r][\n]"
[main] DEBUG org.apache.hc.client5.http.wire - http-outgoing-0 >> "Accept-Encoding: gzip, x-gzip, deflate[\r][\n]"
[main] DEBUG org.apache.hc.client5.http.wire - http-outgoing-0 >> "Host: example.com[\r][\n]"
[main] DEBUG org.apache.hc.client5.http.wire - http-outgoing-0 >> "User-Agent: Apache-HttpClient/5.0 (Java/1.8.0_222)[\r][\n]"
[main] DEBUG org.apache.hc.client5.http.wire - http-outgoing-0 >> "[\r][\n]"
[main] DEBUG org.apache.hc.client5.http.wire - http-outgoing-0 << "HTTP/1.1 407 Proxy authorization required[\r][\n]"
[main] DEBUG org.apache.hc.client5.http.wire - http-outgoing-0 << "Proxy-Authenticate: NTLM[\r][\n]"
[main] DEBUG org.apache.hc.client5.http.wire - http-outgoing-0 << "Proxy-Authenticate: Basic realm="/", charset="UTF-8"[\r][\n]"
[main] DEBUG org.apache.hc.client5.http.wire - http-outgoing-0 << "Proxy-Support: session-based-authentication[\r][\n]"
[main] DEBUG org.apache.hc.client5.http.wire - http-outgoing-0 << "Cache-control: no-store, no-cache[\r][\n]"
[main] DEBUG org.apache.hc.client5.http.wire - http-outgoing-0 << "Content-Type: text/html; charset=utf-8[\r][\n]"
[main] DEBUG org.apache.hc.client5.http.wire - http-outgoing-0 << "Content-Length: 855[\r][\n]"
[main] DEBUG org.apache.hc.client5.http.wire - http-outgoing-0 << "Date: Sun, 05 Apr 2020 06:15:20 GMT[\r][\n]"
[main] DEBUG org.apache.hc.client5.http.wire - http-outgoing-0 << "Server: WinGate Engine[\r][\n]"
[main] DEBUG org.apache.hc.client5.http.wire - http-outgoing-0 << "Connection: Keep-Alive[\r][\n]"
[main] DEBUG org.apache.hc.client5.http.wire - http-outgoing-0 << "[\r][\n]"
[main] DEBUG org.apache.hc.client5.http.wire - http-outgoing-0 << "<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/strict.dtd"><html><head><title>Proxy authorization required</title>[\r][\n]"
[main] DEBUG org.apache.hc.client5.http.wire - http-outgoing-0 << "<style>[\r][\n]"
[main] DEBUG org.apache.hc.client5.http.wire - http-outgoing-0 << "body { font-family:helvetica; font-size:11pt; color:#0071BB; margin:30px; padding:0px; }[\r][\n]"
[main] DEBUG org.apache.hc.client5.http.wire - http-outgoing-0 << "h1 { color:#005395; margin:0px 0px 0px 0px; }[\r][\n]"
[main] DEBUG org.apache.hc.client5.http.wire - http-outgoing-0 << "h2 { color:#005395; }[\r][\n]"
[main] DEBUG org.apache.hc.client5.http.wire - http-outgoing-0 << "p { margin:6px 0px 6px 0px;}[\r][\n]"
[main] DEBUG org.apache.hc.client5.http.wire - http-outgoing-0 << "p.footer { font-size:8pt; margin:3px 0px 0px 0px;}[\r][\n]"
[main] DEBUG org.apache.hc.client5.http.wire - http-outgoing-0 << "b { font-weight:550; color:#7F7F7F; }[\r][\n]"
[main] DEBUG org.apache.hc.client5.http.wire - http-outgoing-0 << "</style>[\r][\n]"
[main] DEBUG org.apache.hc.client5.http.wire - http-outgoing-0 << "</head>[\r][\n]"
[main] DEBUG org.apache.hc.client5.http.wire - http-outgoing-0 << "<body><h1>Proxy authorization required</h1>[\r][\n]"
[main] DEBUG org.apache.hc.client5.http.wire - http-outgoing-0 << "<div style="margin:12px 0px 12px 0px; padding:12px 0px 12px 0px; min-height:300px; border-top:1px solid #0071BB; border-bottom:1px solid #0071BB;">You must authenticate to gain access to this resource</div>[\r][\n]"
[main] DEBUG org.apache.hc.client5.http.wire - http-outgoing-0 << "<p class="footer">WinGate™ © Qbik New Zealand Limited 1995-2020[\r][\n]"
[main] DEBUG org.apache.hc.client5.http.wire - http-outgoing-0 << "</p></body></html>[\r][\n]"
[main] DEBUG org.apache.hc.client5.http.headers - http-outgoing-0 << HTTP/1.1 407 Proxy authorization required
[main] DEBUG org.apache.hc.client5.http.headers - http-outgoing-0 << Proxy-Authenticate: NTLM
[main] DEBUG org.apache.hc.client5.http.headers - http-outgoing-0 << Proxy-Authenticate: Basic realm="/", charset="UTF-8"
[main] DEBUG org.apache.hc.client5.http.headers - http-outgoing-0 << Proxy-Support: session-based-authentication
[main] DEBUG org.apache.hc.client5.http.headers - http-outgoing-0 << Cache-control: no-store, no-cache
[main] DEBUG org.apache.hc.client5.http.headers - http-outgoing-0 << Content-Type: text/html; charset=utf-8
[main] DEBUG org.apache.hc.client5.http.headers - http-outgoing-0 << Content-Length: 855
[main] DEBUG org.apache.hc.client5.http.headers - http-outgoing-0 << Date: Sun, 05 Apr 2020 06:15:20 GMT
[main] DEBUG org.apache.hc.client5.http.headers - http-outgoing-0 << Server: WinGate Engine
[main] DEBUG org.apache.hc.client5.http.headers - http-outgoing-0 << Connection: Keep-Alive
[main] DEBUG org.apache.hc.client5.http.impl.classic.MainClientExec - ex-00000001: connection can be kept alive for 3 MINUTES
[main] DEBUG org.apache.hc.client5.http.impl.classic.ProtocolExec - Authentication required
[main] DEBUG org.apache.hc.client5.http.impl.classic.ProtocolExec - localhost:80 requested authentication
[main] DEBUG org.apache.hc.client5.http.impl.DefaultAuthenticationStrategy - Authentication schemes in the order of preference: [Negotiate, Kerberos, NTLM, Digest, Basic]
[main] DEBUG org.apache.hc.client5.http.impl.DefaultAuthenticationStrategy - Challenge for Negotiate authentication scheme not available
[main] DEBUG org.apache.hc.client5.http.impl.DefaultAuthenticationStrategy - Challenge for Kerberos authentication scheme not available
[main] DEBUG org.apache.hc.client5.http.impl.win.WindowsNegotiateScheme - Created WindowsNegotiateScheme using NTLM
[main] DEBUG org.apache.hc.client5.http.impl.DefaultAuthenticationStrategy - Challenge for Digest authentication scheme not available
[main] WARN org.apache.hc.client5.http.impl.classic.ProtocolExec - Missing auth challenge
[main] DEBUG org.apache.hc.client5.http.impl.io.DefaultManagedHttpClientConnection - http-outgoing-0: close connection GRACEFUL
[main] DEBUG org.apache.hc.client5.http.impl.classic.InternalHttpClient - ep-00000000: endpoint closed
[main] DEBUG org.apache.hc.client5.http.impl.classic.InternalHttpClient - ep-00000000: endpoint closed
[main] DEBUG org.apache.hc.client5.http.impl.classic.InternalHttpClient - ep-00000000: discarding endpoint
[main] DEBUG org.apache.hc.client5.http.impl.io.PoolingHttpClientConnectionManager - ep-00000000: releasing endpoint
[main] DEBUG org.apache.hc.client5.http.impl.io.PoolingHttpClientConnectionManager - ep-00000000: connection released [route: {}->http://localhost:80->http://example.com:80][total available: 0; route allocated: 0 of 5; total allocated: 0 of 25]
[main] DEBUG org.apache.hc.client5.http.impl.io.PoolingHttpClientConnectionManager - Shutdown connection pool GRACEFUL
[main] DEBUG org.apache.hc.client5.http.impl.io.PoolingHttpClientConnectionManager - Connection pool shut down
javax.security.auth.login.CredentialException: Proxy authorization required
at org.kpax.http_client_5_testing.App.main(App.java:47)
Environment
OS: Windows 10
JRE: AdoptOpenJdk v11
Proxy type: NTLM (Wingate)
Question Is there something wrong with the above code?
Obs The same code works fine with Apache Http Client v4.5.12
It is a minor bug, solved now, for v5.0.1.

Kerberos POST request returns 401 error with Java

I'm using KerberosTemplate to make a POST request to a kerberos authenticated rest API.
I can successfully run an insecure request on the command line but when I try to do a secure call with HTTP client It returns a 401 unauthorized error.
I tried to turn of certificate checking as we dont use it and I also tries the username without the domain but that has no affect either.
I also tried to kerb4j rest template too but I get the same issue. From the code you can also see that Im checking the keytab file exists as well.
Appreciate some help, thanks.
import ErrorHandlers.KerberosRestTemplateResponseErrorHandler;
import POJOs.PostBody;
import POJOs.PostResponse;
import com.fasterxml.jackson.databind.SerializationFeature;
//import com.kerb4j.client.spring.KerberosRestTemplate;
import org.springframework.security.kerberos.client.KerberosRestTemplate;
import org.apache.http.conn.ssl.SSLConnectionSocketFactory;
import org.apache.http.conn.ssl.TrustStrategy;
import org.apache.http.impl.client.CloseableHttpClient;
import org.apache.http.impl.client.HttpClients;
import org.springframework.http.HttpEntity;
import org.springframework.http.HttpHeaders;
import org.springframework.http.MediaType;
import org.springframework.http.client.HttpComponentsClientHttpRequestFactory;
import org.springframework.http.converter.json.MappingJackson2HttpMessageConverter;
import javax.net.ssl.SSLContext;
import java.io.File;
import java.security.KeyManagementException;
import java.security.KeyStoreException;
import java.security.NoSuchAlgorithmException;
import java.security.cert.X509Certificate;
public class KerbTemplate {
public static void main(String[] args) throws KeyStoreException, NoSuchAlgorithmException, KeyManagementException {
PostBody postRequestBody = new PostBody();
postRequestBody.setAggregation("data");
postRequestBody.setEndDate("2119-03-30");
postRequestBody.setStartDate("1900-03-30");
postRequestBody.setMetadata(new String[] {"PARTIAL"});
postRequestBody.setSymbols(new String[] {"requestdata"});
postRequestBody.setModifiedDate("2019-07-20");
postRequestBody.setFirstWeekday("0");
TrustStrategy acceptingTrustStrategy = ((X509Certificate[] chain, String authType) -> true);
SSLContext sslContext = org.apache.http.ssl.SSLContexts.custom().loadTrustMaterial(null, acceptingTrustStrategy).build();
SSLConnectionSocketFactory csf = new SSLConnectionSocketFactory(sslContext);
CloseableHttpClient httpClient = HttpClients.custom().setSSLSocketFactory(csf).build();
HttpComponentsClientHttpRequestFactory requestFactory = new HttpComponentsClientHttpRequestFactory();
requestFactory.setHttpClient(httpClient);
String base = System.getProperty("user.dir");
String keytab = base+ File.separator+"src"+File.separator+"main"+File.separator+"resources"+File.separator+"username.keytab";
System.out.println(keytab);
File f = new File(keytab);
if(f.exists() && !f.isDirectory()) {
System.out.println("File exists");
}
KerberosRestTemplate kerberosRestTemplate = new KerberosRestTemplate( keytab,"'username#domain",requestFactory.getHttpClient());
kerberosRestTemplate.setErrorHandler(new KerberosRestTemplateResponseErrorHandler());
MappingJackson2HttpMessageConverter jsonHttpMessageConverter = new MappingJackson2HttpMessageConverter();
jsonHttpMessageConverter.getObjectMapper().configure(SerializationFeature.FAIL_ON_EMPTY_BEANS, false);
kerberosRestTemplate.getMessageConverters().add(jsonHttpMessageConverter);
// Add CSRF header if required:
HttpHeaders headers = new HttpHeaders();
headers.set("X-Requested-By", "'username#domain");
headers.setContentType(MediaType.APPLICATION_JSON);
headers.set("Client-Type","Web");
headers.set("Client-UI-Component","Jim");
HttpEntity<PostBody> postRequest = new HttpEntity<PostBody>(postRequestBody, headers);
PostResponse pr = kerberosRestTemplate.postForObject("https://url.com/1/data/loadList", postRequest, PostResponse.class);
}
}
package ErrorHandlers;
import org.springframework.http.HttpStatus;
import org.springframework.http.client.ClientHttpResponse;
import org.springframework.web.client.ResponseErrorHandler;
import java.io.IOException;
public class KerberosRestTemplateResponseErrorHandler implements ResponseErrorHandler {
#Override
public boolean hasError(ClientHttpResponse httpResponse) throws IOException {
return (
httpResponse.getStatusCode().series() == HttpStatus.Series.CLIENT_ERROR
|| httpResponse.getStatusCode().series() == HttpStatus.Series.SERVER_ERROR);
}
#Override
public void handleError(ClientHttpResponse httpResponse) throws IOException {
System.out.println("Error Response code " + httpResponse.getRawStatusCode());
System.out.println(httpResponse.getStatusText());
System.out.println(httpResponse.getBody().toString());
}
}
Updated with Partial logs
1:56:58.233 [Finalizer] DEBUG org.apache.http.impl.conn.PoolingHttpClientConnectionManager - Connection manager is shutting down
21:56:58.245 [Finalizer] DEBUG org.apache.http.impl.conn.PoolingHttpClientConnectionManager - Connection manager shut down
21:58:30.261 [main] DEBUG org.springframework.security.kerberos.client.KerberosRestTemplate - HTTP POST myendpoint.com
21:58:30.460 [main] DEBUG org.springframework.security.kerberos.client.KerberosRestTemplate - Accept=[application/json, application/*+json]
21:58:30.500 [main] DEBUG org.springframework.security.kerberos.client.KerberosRestTemplate - Writing [ClassPojo [firstWeekday = 0, metadata = [Ljava.lang.String;#2f465398, endDate = 2119-03-30, modifiedDate = 2019-07-20, aggregation = DAILY, symbols = [Ljava.lang.String;#548e6d58, startDate = 1900-03-30]] as "application/json"
21:58:30.540 [main] DEBUG org.apache.http.client.protocol.RequestAddCookies - CookieSpec selected: default
21:58:30.561 [main] DEBUG org.apache.http.client.protocol.RequestAuthCache - Auth cache not set in the context
21:58:30.565 [main] DEBUG org.apache.http.impl.conn.PoolingHttpClientConnectionManager - Connection request: [route: {s}->myendpoint.com:443][total kept alive: 0; route allocated: 0 of 2; total allocated: 0 of 20]
21:58:30.587 [main] DEBUG org.apache.http.impl.conn.PoolingHttpClientConnectionManager - Connection leased: [id: 0][route: {s}->myendpoint.com:443][total kept alive: 0; route allocated: 1 of 2; total allocated: 1 of 20]
21:58:30.591 [main] DEBUG org.apache.http.impl.execchain.MainClientExec - Opening connection {s}->myendpoint.com:443
21:58:30.617 [main] DEBUG org.apache.http.impl.conn.DefaultHttpClientConnectionOperator - Connecting to myendpoint.com:443
21:58:30.617 [main] DEBUG org.apache.http.conn.ssl.SSLConnectionSocketFactory - Connecting socket to myendpoint.com:443 with timeout 0
21:58:30.747 [main] DEBUG org.apache.http.conn.ssl.SSLConnectionSocketFactory - Enabled protocols: [TLSv1, TLSv1.1, TLSv1.2]
21:58:30.747 [main] DEBUG org.apache.http.conn.ssl.SSLConnectionSocketFactory - Enabled cipher suites:[TLS_ECDHE_ECDSA_WITH_AES_256_CBC_SHA384, TLS_ECDHE_RSA_WITH_AES_256_CBC_SHA384, TLS_RSA_WITH_AES_256_CBC_SHA256, TLS_ECDH_ECDSA_WITH_AES_256_CBC_SHA384, TLS_ECDH_RSA_WITH_AES_256_CBC_SHA384, TLS_DHE_RSA_WITH_AES_256_CBC_SHA256, TLS_DHE_DSS_WITH_AES_256_CBC_SHA256, TLS_ECDHE_ECDSA_WITH_AES_256_CBC_SHA, TLS_ECDHE_RSA_WITH_AES_256_CBC_SHA, TLS_RSA_WITH_AES_256_CBC_SHA, TLS_ECDH_ECDSA_WITH_AES_256_CBC_SHA, TLS_ECDH_RSA_WITH_AES_256_CBC_SHA, TLS_DHE_RSA_WITH_AES_256_CBC_SHA, TLS_DHE_DSS_WITH_AES_256_CBC_SHA, TLS_ECDHE_ECDSA_WITH_AES_128_CBC_SHA256, TLS_ECDHE_RSA_WITH_AES_128_CBC_SHA256, TLS_RSA_WITH_AES_128_CBC_SHA256, TLS_ECDH_ECDSA_WITH_AES_128_CBC_SHA256, TLS_ECDH_RSA_WITH_AES_128_CBC_SHA256, TLS_DHE_RSA_WITH_AES_128_CBC_SHA256, TLS_DHE_DSS_WITH_AES_128_CBC_SHA256, TLS_ECDHE_ECDSA_WITH_AES_128_CBC_SHA, TLS_ECDHE_RSA_WITH_AES_128_CBC_SHA, TLS_RSA_WITH_AES_128_CBC_SHA, TLS_ECDH_ECDSA_WITH_AES_128_CBC_SHA, TLS_ECDH_RSA_WITH_AES_128_CBC_SHA, TLS_DHE_RSA_WITH_AES_128_CBC_SHA, TLS_DHE_DSS_WITH_AES_128_CBC_SHA, TLS_ECDHE_ECDSA_WITH_AES_256_GCM_SHA384, TLS_ECDHE_ECDSA_WITH_AES_128_GCM_SHA256, TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384, TLS_RSA_WITH_AES_256_GCM_SHA384, TLS_ECDH_ECDSA_WITH_AES_256_GCM_SHA384, TLS_ECDH_RSA_WITH_AES_256_GCM_SHA384, TLS_DHE_RSA_WITH_AES_256_GCM_SHA384, TLS_DHE_DSS_WITH_AES_256_GCM_SHA384, TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256, TLS_RSA_WITH_AES_128_GCM_SHA256, TLS_ECDH_ECDSA_WITH_AES_128_GCM_SHA256, TLS_ECDH_RSA_WITH_AES_128_GCM_SHA256, TLS_DHE_RSA_WITH_AES_128_GCM_SHA256, TLS_DHE_DSS_WITH_AES_128_GCM_SHA256, TLS_EMPTY_RENEGOTIATION_INFO_SCSV]
21:58:30.747 [main] DEBUG org.apache.http.conn.ssl.SSLConnectionSocketFactory - Starting handshake
21:58:30.923 [main] DEBUG org.apache.http.conn.ssl.SSLConnectionSocketFactory - Secure session established
21:58:30.923 [main] DEBUG org.apache.http.conn.ssl.SSLConnectionSocketFactory - negotiated protocol: TLSv1.2
21:58:30.924 [main] DEBUG org.apache.http.conn.ssl.SSLConnectionSocketFactory - negotiated cipher suite: TLS_ECDHE_RSA_WITH_AES_256_CBC_SHA384
21:58:30.933 [main] DEBUG org.apache.http.conn.ssl.SSLConnectionSocketFactory - peer principal: CN=myendpoint.com, O=EXAMPLE p.l.c.
21:58:30.934 [main] DEBUG org.apache.http.conn.ssl.SSLConnectionSocketFactory - peer alternative names: [myendpoint.com]
21:58:30.962 [main] DEBUG org.apache.http.impl.execchain.MainClientExec - Executing request POST /1/data/loadList HTTP/1.1
21:58:30.963 [main] DEBUG org.apache.http.impl.execchain.MainClientExec - Target auth state: UNCHALLENGED
21:58:30.968 [main] DEBUG org.apache.http.impl.execchain.MainClientExec - Proxy auth state: UNCHALLENGED
21:58:30.976 [main] DEBUG org.apache.http.headers - http-outgoing-0 >> POST /1/data/loadList HTTP/1.1
21:58:30.979 [main] DEBUG org.apache.http.headers - http-outgoing-0 >> Accept: application/json, application/+json
21:58:30.979 [main] DEBUG org.apache.http.headers - http-outgoing-0 >> Client-Type: Fred
21:58:30.980 [main] DEBUG org.apache.http.headers - http-outgoing-0 >> Content-Type: application/json
21:58:30.981 [main] DEBUG org.apache.http.headers - http-outgoing-0 >> Client-UI-Component: Jim
21:58:30.981 [main] DEBUG org.apache.http.headers - http-outgoing-0 >> Content-Length: 220
21:58:30.982 [main] DEBUG org.apache.http.headers - http-outgoing-0 >> Host: myendpoint.com
21:58:30.983 [main] DEBUG org.apache.http.headers - http-outgoing-0 >> Connection: Keep-Alive
21:58:30.983 [main] DEBUG org.apache.http.headers - http-outgoing-0 >> User-Agent: Apache-HttpClient/4.5.9 (Java/1.8.0_212-3-redhat)
21:58:30.983 [main] DEBUG org.apache.http.headers - http-outgoing-0 >> Accept-Encoding: gzip,deflate
21:58:30.984 [main] DEBUG org.apache.http.wire - http-outgoing-0 >> "POST /1/data/loadList HTTP/1.1[\r][\n]"
21:58:30.984 [main] DEBUG org.apache.http.wire - http-outgoing-0 >> "Accept: application/json, application/+json[\r][\n]"
21:58:30.984 [main] DEBUG org.apache.http.wire - http-outgoing-0 >> "Client-Type: Fred[\r][\n]"
21:58:30.985 [main] DEBUG org.apache.http.wire - http-outgoing-0 >> "Content-Type: application/json[\r][\n]"
21:58:30.986 [main] DEBUG org.apache.http.wire - http-outgoing-0 >> "Client-UI-Component: Jim[\r][\n]"
21:58:30.986 [main] DEBUG org.apache.http.wire - http-outgoing-0 >> "Content-Length: 220[\r][\n]"
21:58:30.986 [main] DEBUG org.apache.http.wire - http-outgoing-0 >> "Host: myendpoint.com[\r][\n]"
21:58:30.988 [main] DEBUG org.apache.http.wire - http-outgoing-0 >> "Connection: Keep-Alive[\r][\n]"
21:58:30.990 [main] DEBUG org.apache.http.wire - http-outgoing-0 >> "User-Agent: Apache-HttpClient/4.5.9 (Java/1.8.0_212-3-redhat)[\r][\n]"
21:58:30.990 [main] DEBUG org.apache.http.wire - http-outgoing-0 >> "Accept-Encoding: gzip,deflate[\r][\n]"
21:58:30.991 [main] DEBUG org.apache.http.wire - http-outgoing-0 >> "[\r][\n]"
21:58:30.992 [main] DEBUG org.apache.http.wire - http-outgoing-0 >> "{"firstWeekday":"0","metadata":["All"],"endDate":"2119-03-30","modifiedDate":"2019-07-20","aggregation":"DAILY","symbols":["symbol1","symbol2"],"startDate":"1900-03-30"}"
21:58:31.043 [main] DEBUG org.apache.http.wire - http-outgoing-0 << "HTTP/1.1 401 [\r][\n]"
21:58:31.043 [main] DEBUG org.apache.http.wire - http-outgoing-0 << "Access-Control-Allow-Credentials: true[\r][\n]"
21:58:31.043 [main] DEBUG org.apache.http.wire - http-outgoing-0 << "Access-Control-Allow-Methods: POST, GET, OPTIONS, DELETE[\r][\n]"
21:58:31.043 [main] DEBUG org.apache.http.wire - http-outgoing-0 << "Access-Control-Max-Age: 3600[\r][\n]"
21:58:31.043 [main] DEBUG org.apache.http.wire - http-outgoing-0 << "Access-Control-Allow-Headers: Client-Type, Content-Type, Accept, X-Requested-With, Authorization, rejectunauthorized[\r][\n]"
21:58:31.044 [main] DEBUG org.apache.http.wire - http-outgoing-0 << "WWW-Authenticate: Negotiate[\r][\n]"
21:58:31.044 [main] DEBUG org.apache.http.wire - http-outgoing-0 << "X-Content-Type-Options: nosniff[\r][\n]"
21:58:31.044 [main] DEBUG org.apache.http.wire - http-outgoing-0 << "X-XSS-Protection: 1; mode=block[\r][\n]"
21:58:31.044 [main] DEBUG org.apache.http.wire - http-outgoing-0 << "Cache-Control: no-cache, no-store, max-age=0, must-revalidate[\r][\n]"
21:58:31.044 [main] DEBUG org.apache.http.wire - http-outgoing-0 << "Pragma: no-cache[\r][\n]"
21:58:31.044 [main] DEBUG org.apache.http.wire - http-outgoing-0 << "Expires: 0[\r][\n]"
21:58:31.044 [main] DEBUG org.apache.http.wire - http-outgoing-0 << "Strict-Transport-Security: max-age=31536000 ; includeSubDomains[\r][\n]"
21:58:31.044 [main] DEBUG org.apache.http.wire - http-outgoing-0 << "X-Frame-Options: DENY[\r][\n]"
21:58:31.044 [main] DEBUG org.apache.http.wire - http-outgoing-0 << "Transfer-Encoding: chunked[\r][\n]"
21:58:31.044 [main] DEBUG org.apache.http.wire - http-outgoing-0 << "Date: Wed, 11 Sep 2019 20:58:31 GMT[\r][\n]"
21:58:31.044 [main] DEBUG org.apache.http.wire - http-outgoing-0 << "[\r][\n]"
21:58:31.050 [main] DEBUG org.apache.http.headers - http-outgoing-0 << HTTP/1.1 401
21:58:31.050 [main] DEBUG org.apache.http.headers - http-outgoing-0 << Access-Control-Allow-Credentials: true
21:58:31.050 [main] DEBUG org.apache.http.headers - http-outgoing-0 << Access-Control-Allow-Methods: POST, GET, OPTIONS, DELETE
21:58:31.051 [main] DEBUG org.apache.http.headers - http-outgoing-0 << Access-Control-Max-Age: 3600
21:58:31.051 [main] DEBUG org.apache.http.headers - http-outgoing-0 << Access-Control-Allow-Headers: Client-Type, Content-Type, Accept, X-Requested-With, Authorization, rejectunauthorized
21:58:31.051 [main] DEBUG org.apache.http.headers - http-outgoing-0 << WWW-Authenticate: Negotiate
21:58:31.051 [main] DEBUG org.apache.http.headers - http-outgoing-0 << X-Content-Type-Options: nosniff
21:58:31.051 [main] DEBUG org.apache.http.headers - http-outgoing-0 << X-XSS-Protection: 1; mode=block
21:58:31.051 [main] DEBUG org.apache.http.headers - http-outgoing-0 << Cache-Control: no-cache, no-store, max-age=0, must-revalidate
21:58:31.051 [main] DEBUG org.apache.http.headers - http-outgoing-0 << Pragma: no-cache
21:58:31.051 [main] DEBUG org.apache.http.headers - http-outgoing-0 << Expires: 0
21:58:31.051 [main] DEBUG org.apache.http.headers - http-outgoing-0 << Strict-Transport-Security: max-age=31536000 ; includeSubDomains
21:58:31.051 [main] DEBUG org.apache.http.headers - http-outgoing-0 << X-Frame-Options: DENY
21:58:31.051 [main] DEBUG org.apache.http.headers - http-outgoing-0 << Transfer-Encoding: chunked
21:58:31.051 [main] DEBUG org.apache.http.headers - http-outgoing-0 << Date: Wed, 11 Sep 2019 20:58:31 GMT
21:58:31.063 [main] DEBUG org.apache.http.impl.execchain.MainClientExec - Connection can be kept alive indefinitely
21:58:31.063 [main] DEBUG org.apache.http.impl.auth.HttpAuthenticator - Authentication required
21:58:31.063 [main] DEBUG org.apache.http.impl.auth.HttpAuthenticator - myendpoint.com:443 requested authentication
21:58:31.063 [main] DEBUG org.apache.http.impl.client.TargetAuthenticationStrategy - Authentication schemes in the order of preference: [Negotiate, Kerberos, NTLM, CredSSP, Digest, Basic]
21:58:31.081 [main] DEBUG org.apache.http.impl.auth.SPNegoScheme - Received challenge '' from the auth server
21:58:31.082 [main] DEBUG org.apache.http.impl.client.TargetAuthenticationStrategy - Challenge for Kerberos authentication scheme not available
21:58:31.083 [main] DEBUG org.apache.http.impl.client.TargetAuthenticationStrategy - Challenge for NTLM authentication scheme not available
21:58:31.083 [main] DEBUG org.apache.http.impl.client.TargetAuthenticationStrategy - Challenge for CredSSP authentication scheme not available
21:58:31.083 [main] DEBUG org.apache.http.impl.client.TargetAuthenticationStrategy - Challenge for Digest authentication scheme not available
21:58:31.083 [main] DEBUG org.apache.http.impl.client.TargetAuthenticationStrategy - Challenge for Basic authentication scheme not available
21:58:31.093 [main] DEBUG org.springframework.security.kerberos.client.KerberosRestTemplate - Response 401 UNAUTHORIZED
Error Response code 401
21:58:31.096 [main] DEBUG org.apache.http.wire - http-outgoing-0 << "0[\r][\n]"
21:58:31.097 [main] DEBUG org.apache.http.wire - http-outgoing-0 << "[\r][\n]"
21:58:31.097 [main] DEBUG org.apache.http.impl.conn.PoolingHttpClientConnectionManager - Connection [id: 0][route: {s}->myendpoint.com:443] can be kept alive indefinitely
21:58:31.097 [main] DEBUG org.apache.http.impl.conn.DefaultManagedHttpClientConnection - http-outgoing-0: set socket timeout to 0
21:58:31.097 [main] DEBUG org.apache.http.impl.conn.PoolingHttpClientConnectionManager - Connection released: [id: 0][route: {s}->myendpoint.com:443][total kept alive: 1; route allocated: 1 of 2; total allocated: 1 of 20]
Process finished with exit code 0

Quickbooks integration error number 401

I'm new to quickbooks technology, I want to make an integration between Quick books and (CRUD-SampleApp-Java) application, each time I run "CustomerCreate" class I get this error:
"Error while calling entity add:: message=AuthenticationFailed; errorCode=003200; statusCode=401"
SLF4J: Class path contains multiple SLF4J bindings.
SLF4J: Found binding in [jar:file:/C:/Users/kjaber/.m2/repository/org/slf4j/slf4j-log4j12/1.7.25/slf4j-log4j12-1.7.25.jar!/org/slf4j/impl/StaticLoggerBinder.class]
SLF4J: Found binding in [jar:file:/C:/Users/kjaber/.m2/repository/org/slf4j/slf4j-log4j12/1.7.21/slf4j-log4j12-1.7.21.jar!/org/slf4j/impl/StaticLoggerBinder.class]
SLF4J: See http://www.slf4j.org/codes.html#multiple_bindings for an explanation.
SLF4J: Actual binding is of type [org.slf4j.impl.Log4jLoggerFactory]
0 [main] DEBUG org.apache.commons.configuration.ConfigurationUtils - ConfigurationUtils.locate(): base is null, name is intuit-config.xml
4 [main] DEBUG org.apache.commons.configuration.ConfigurationUtils - Loading configuration from the context classpath (intuit-config.xml)
34 [main] DEBUG org.apache.commons.configuration.ConfigurationUtils - ConfigurationUtils.locate(): base is null, name is intuit-default-config.xml
35 [main] DEBUG org.apache.commons.configuration.ConfigurationUtils - Loading configuration from the context classpath (intuit-default-config.xml)
63 [main] DEBUG com.intuit.logger - Enter PrepareRequestInterceptor...
149 [main] DEBUG com.intuit.logger - Exit PrepareRequestInterceptor.
149 [main] DEBUG com.intuit.logger - Enter SerializeInterceptor...
149 [main] INFO com.intuit.logger - serialization format : json
517 [main] DEBUG com.intuit.logger - Exit SerializeInterceptor.
517 [main] DEBUG com.intuit.logger - Enter CompressionInterceptor...
517 [main] INFO com.intuit.logger - compression format : gzip
519 [main] DEBUG com.intuit.logger - Exit CompressionInterceptor.
519 [main] DEBUG com.intuit.logger - Enter HTTPClientConnectionInterceptor...
856 [main] DEBUG com.intuit.logger - Request URI : https://sandbox-quickbooks.api.intuit.com/v3/company/193514552765139/customer?requestid=aa62bd10e21848f8a1ade7f666e59546&minorversion=12&
856 [main] DEBUG com.intuit.logger - Http Method : POST
856 [main] DEBUG com.intuit.logger - Request Body : {"DisplayName":"0hmQ77"}
868 [main] DEBUG org.apache.http.client.protocol.RequestAddCookies - CookieSpec selected: default
877 [main] DEBUG org.apache.http.client.protocol.RequestAuthCache - Auth cache not set in the context
878 [main] DEBUG org.apache.http.impl.conn.PoolingHttpClientConnectionManager - Connection request: [route: {s}->https://sandbox-quickbooks.api.intuit.com:443][total kept alive: 0; route allocated: 0 of 2; total allocated: 0 of 20]
891 [main] DEBUG org.apache.http.impl.conn.PoolingHttpClientConnectionManager - Connection leased: [id: 0][route: {s}->https://sandbox-quickbooks.api.intuit.com:443][total kept alive: 0; route allocated: 1 of 2; total allocated: 1 of 20]
892 [main] DEBUG org.apache.http.impl.execchain.MainClientExec - Opening connection {s}->https://sandbox-quickbooks.api.intuit.com:443
1133 [main] DEBUG org.apache.http.impl.conn.DefaultHttpClientConnectionOperator - Connecting to sandbox-quickbooks.api.intuit.com/12.149.173.155:443
1133 [main] DEBUG org.apache.http.conn.ssl.SSLConnectionSocketFactory - Connecting socket to sandbox-quickbooks.api.intuit.com/12.149.173.155:443 with timeout 0
1410 [main] DEBUG org.apache.http.conn.ssl.SSLConnectionSocketFactory - Enabled protocols: [TLSv1, TLSv1.1, TLSv1.2]
1410 [main] DEBUG org.apache.http.conn.ssl.SSLConnectionSocketFactory - Enabled cipher suites:[TLS_ECDHE_ECDSA_WITH_AES_128_CBC_SHA256, TLS_ECDHE_RSA_WITH_AES_128_CBC_SHA256, TLS_RSA_WITH_AES_128_CBC_SHA256, TLS_ECDH_ECDSA_WITH_AES_128_CBC_SHA256, TLS_ECDH_RSA_WITH_AES_128_CBC_SHA256, TLS_DHE_RSA_WITH_AES_128_CBC_SHA256, TLS_DHE_DSS_WITH_AES_128_CBC_SHA256, TLS_ECDHE_ECDSA_WITH_AES_128_CBC_SHA, TLS_ECDHE_RSA_WITH_AES_128_CBC_SHA, TLS_RSA_WITH_AES_128_CBC_SHA, TLS_ECDH_ECDSA_WITH_AES_128_CBC_SHA, TLS_ECDH_RSA_WITH_AES_128_CBC_SHA, TLS_DHE_RSA_WITH_AES_128_CBC_SHA, TLS_DHE_DSS_WITH_AES_128_CBC_SHA, TLS_ECDHE_ECDSA_WITH_AES_128_GCM_SHA256, TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256, TLS_RSA_WITH_AES_128_GCM_SHA256, TLS_ECDH_ECDSA_WITH_AES_128_GCM_SHA256, TLS_ECDH_RSA_WITH_AES_128_GCM_SHA256, TLS_DHE_RSA_WITH_AES_128_GCM_SHA256, TLS_DHE_DSS_WITH_AES_128_GCM_SHA256, TLS_ECDHE_ECDSA_WITH_3DES_EDE_CBC_SHA, TLS_ECDHE_RSA_WITH_3DES_EDE_CBC_SHA, SSL_RSA_WITH_3DES_EDE_CBC_SHA, TLS_ECDH_ECDSA_WITH_3DES_EDE_CBC_SHA, TLS_ECDH_RSA_WITH_3DES_EDE_CBC_SHA, SSL_DHE_RSA_WITH_3DES_EDE_CBC_SHA, SSL_DHE_DSS_WITH_3DES_EDE_CBC_SHA, TLS_EMPTY_RENEGOTIATION_INFO_SCSV]
1410 [main] DEBUG org.apache.http.conn.ssl.SSLConnectionSocketFactory - Starting handshake
2209 [main] DEBUG org.apache.http.conn.ssl.SSLConnectionSocketFactory - Secure session established
2209 [main] DEBUG org.apache.http.conn.ssl.SSLConnectionSocketFactory - negotiated protocol: TLSv1.2
2209 [main] DEBUG org.apache.http.conn.ssl.SSLConnectionSocketFactory - negotiated cipher suite: TLS_DHE_RSA_WITH_AES_128_GCM_SHA256
2210 [main] DEBUG org.apache.http.conn.ssl.SSLConnectionSocketFactory - peer principal: CN=*.api.intuit.com, OU=CTO-DEV-ICS Ops, O=INTUIT INC., L=San Diego, ST=California, C=US
2210 [main] DEBUG org.apache.http.conn.ssl.SSLConnectionSocketFactory - peer alternative names: [api.intuit.com, *.api.intuit.com, api.intuit.net, *.api.intuit.net]
2211 [main] DEBUG org.apache.http.conn.ssl.SSLConnectionSocketFactory - issuer principal: CN=Symantec Class 3 Secure Server CA - G4, OU=Symantec Trust Network, O=Symantec Corporation, C=US
2217 [main] DEBUG org.apache.http.impl.conn.DefaultHttpClientConnectionOperator - Connection established 172.16.1.19:60298<->12.149.173.155:443
2217 [main] DEBUG org.apache.http.impl.conn.DefaultManagedHttpClientConnection - http-outgoing-0: set socket timeout to 0
2217 [main] DEBUG org.apache.http.impl.execchain.MainClientExec - Executing request POST /v3/company/193514552765139/customer?requestid=aa62bd10e21848f8a1ade7f666e59546&minorversion=12& HTTP/1.1
2218 [main] DEBUG org.apache.http.impl.execchain.MainClientExec - Proxy auth state: UNCHALLENGED
2221 [main] DEBUG org.apache.http.headers - http-outgoing-0 >> POST /v3/company/193514552765139/customer?requestid=aa62bd10e21848f8a1ade7f666e59546&minorversion=12& HTTP/1.1
2221 [main] DEBUG org.apache.http.headers - http-outgoing-0 >> Accept: application/json
2221 [main] DEBUG org.apache.http.headers - http-outgoing-0 >> Content-Encoding: gzip
2221 [main] DEBUG org.apache.http.headers - http-outgoing-0 >> content-type: application/json
2221 [main] DEBUG org.apache.http.headers - http-outgoing-0 >> Accept-Encoding: gzip
2221 [main] DEBUG org.apache.http.headers - http-outgoing-0 >> User-Agent: V3JavaSDK3.0.0
2221 [main] DEBUG org.apache.http.headers - http-outgoing-0 >> Authorization: Bearer L011505900548zBbxMrQrmfBnApHFLwR8KslQ7zzVL2fgB0XaJ
2221 [main] DEBUG org.apache.http.headers - http-outgoing-0 >> Content-Length: 44
2221 [main] DEBUG org.apache.http.headers - http-outgoing-0 >> Host: sandbox-quickbooks.api.intuit.com
2221 [main] DEBUG org.apache.http.headers - http-outgoing-0 >> Connection: Keep-Alive
2222 [main] DEBUG org.apache.http.wire - http-outgoing-0 >> "POST /v3/company/193514552765139/customer?requestid=aa62bd10e21848f8a1ade7f666e59546&minorversion=12& HTTP/1.1[\r][\n]"
2222 [main] DEBUG org.apache.http.wire - http-outgoing-0 >> "Accept: application/json[\r][\n]"
2222 [main] DEBUG org.apache.http.wire - http-outgoing-0 >> "Content-Encoding: gzip[\r][\n]"
2222 [main] DEBUG org.apache.http.wire - http-outgoing-0 >> "content-type: application/json[\r][\n]"
2222 [main] DEBUG org.apache.http.wire - http-outgoing-0 >> "Accept-Encoding: gzip[\r][\n]"
2222 [main] DEBUG org.apache.http.wire - http-outgoing-0 >> "User-Agent: V3JavaSDK3.0.0[\r][\n]"
2222 [main] DEBUG org.apache.http.wire - http-outgoing-0 >> "Authorization: Bearer L011505900548zBbxMrQrmfBnApHFLwR8KslQ7zzVL2fgB0XaJ[\r][\n]"
2222 [main] DEBUG org.apache.http.wire - http-outgoing-0 >> "Content-Length: 44[\r][\n]"
2222 [main] DEBUG org.apache.http.wire - http-outgoing-0 >> "Host: sandbox-quickbooks.api.intuit.com[\r][\n]"
2223 [main] DEBUG org.apache.http.wire - http-outgoing-0 >> "Connection: Keep-Alive[\r][\n]"
2223 [main] DEBUG org.apache.http.wire - http-outgoing-0 >> "[\r][\n]"
2223 [main] DEBUG org.apache.http.wire - http-outgoing-0 >> "[0x1f][0x8b][0x8][0x0][0x0][0x0][0x0][0x0][0x0][0x0][0xab]Vr[0xc9],.[0xc8]I[0xac][0xf4]K[0xcc]MU[0xb2]R2[0xc8][0xc8][\r]47W[0xaa][0x5][0x0]&[0xe6][0xb0][0x18][0x0][0x0][0x0]"
2490 [main] DEBUG org.apache.http.wire - http-outgoing-0 << "HTTP/1.1 401 Unauthorized[\r][\n]"
2490 [main] DEBUG org.apache.http.wire - http-outgoing-0 << "Server: nginx[\r][\n]"
2490 [main] DEBUG org.apache.http.wire - http-outgoing-0 << "Date: Wed, 20 Sep 2017 09:37:07 GMT[\r][\n]"
2490 [main] DEBUG org.apache.http.wire - http-outgoing-0 << "Content-Type: text/xml[\r][\n]"
2490 [main] DEBUG org.apache.http.wire - http-outgoing-0 << "Content-Length: 388[\r][\n]"
2490 [main] DEBUG org.apache.http.wire - http-outgoing-0 << "Connection: keep-alive[\r][\n]"
2490 [main] DEBUG org.apache.http.wire - http-outgoing-0 << "Keep-Alive: timeout=5[\r][\n]"
2490 [main] DEBUG org.apache.http.wire - http-outgoing-0 << "intuit_tid: 9856d20d-f8ce-d77c-024f-3cdcf258e401[\r][\n]"
2491 [main] DEBUG org.apache.http.wire - http-outgoing-0 << "WWW-Authenticate: Bearer realm="Intuit", error="invalid_token"[\r][\n]"
2491 [main] DEBUG org.apache.http.wire - http-outgoing-0 << "[\r][\n]"
2491 [main] DEBUG org.apache.http.wire - http-outgoing-0 << "<?xml version="1.0" encoding="UTF-8" standalone="yes"?>[\n]"
2491 [main] DEBUG org.apache.http.wire - http-outgoing-0 << "<IntuitResponse time="2017-09-20T02:37:07.562-07:00" xmlns="http://schema.intuit.com/finance/v3">[\n]"
2491 [main] DEBUG org.apache.http.wire - http-outgoing-0 << " <Fault type="AUTHENTICATION">[\n]"
2491 [main] DEBUG org.apache.http.wire - http-outgoing-0 << " <Error code="3200">[\n]"
2491 [main] DEBUG org.apache.http.wire - http-outgoing-0 << " <Message>message=AuthenticationFailed; errorCode=003200; statusCode=401</Message>[\n]"
2491 [main] DEBUG org.apache.http.wire - http-outgoing-0 << " <Detail></Detail>[\n]"
2491 [main] DEBUG org.apache.http.wire - http-outgoing-0 << " </Error>[\n]"
2491 [main] DEBUG org.apache.http.wire - http-outgoing-0 << " </Fault>[\n]"
2491 [main] DEBUG org.apache.http.wire - http-outgoing-0 << "</IntuitResponse>[\n]"
2495 [main] DEBUG org.apache.http.headers - http-outgoing-0 << HTTP/1.1 401 Unauthorized
2495 [main] DEBUG org.apache.http.headers - http-outgoing-0 << Server: nginx
2495 [main] DEBUG org.apache.http.headers - http-outgoing-0 << Date: Wed, 20 Sep 2017 09:37:07 GMT
2495 [main] DEBUG org.apache.http.headers - http-outgoing-0 << Content-Type: text/xml
2496 [main] DEBUG org.apache.http.headers - http-outgoing-0 << Content-Length: 388
2496 [main] DEBUG org.apache.http.headers - http-outgoing-0 << Connection: keep-alive
2496 [main] DEBUG org.apache.http.headers - http-outgoing-0 << Keep-Alive: timeout=5
2496 [main] DEBUG org.apache.http.headers - http-outgoing-0 << intuit_tid: 9856d20d-f8ce-d77c-024f-3cdcf258e401
2496 [main] DEBUG org.apache.http.headers - http-outgoing-0 << WWW-Authenticate: Bearer realm="Intuit", error="invalid_token"
2503 [main] DEBUG org.apache.http.impl.execchain.MainClientExec - Connection can be kept alive for 5000 MILLISECONDS
2503 [main] DEBUG org.apache.http.impl.auth.HttpAuthenticator - Authentication required
2503 [main] DEBUG org.apache.http.impl.auth.HttpAuthenticator - sandbox-quickbooks.api.intuit.com:443 requested authentication
2503 [main] DEBUG org.apache.http.impl.client.TargetAuthenticationStrategy - Authentication schemes in the order of preference: [Negotiate, Kerberos, NTLM, Digest, Basic]
2503 [main] DEBUG org.apache.http.impl.client.TargetAuthenticationStrategy - Challenge for Negotiate authentication scheme not available
2503 [main] DEBUG org.apache.http.impl.client.TargetAuthenticationStrategy - Challenge for Kerberos authentication scheme not available
2504 [main] DEBUG org.apache.http.impl.client.TargetAuthenticationStrategy - Challenge for NTLM authentication scheme not available
2504 [main] DEBUG org.apache.http.impl.client.TargetAuthenticationStrategy - Challenge for Digest authentication scheme not available
2504 [main] DEBUG org.apache.http.impl.client.TargetAuthenticationStrategy - Challenge for Basic authentication scheme not available
2508 [main] DEBUG com.intuit.logger - Connection status : HTTP/1.1 401 Unauthorized
2509 [main] DEBUG org.apache.http.impl.conn.PoolingHttpClientConnectionManager - Connection [id: 0][route: {s}->https://sandbox-quickbooks.api.intuit.com:443] can be kept alive for 5.0 seconds
2509 [main] DEBUG org.apache.http.impl.conn.PoolingHttpClientConnectionManager - Connection released: [id: 0][route: {s}->https://sandbox-quickbooks.api.intuit.com:443][total kept alive: 1; route allocated: 1 of 2; total allocated: 1 of 20]
2509 [main] DEBUG org.apache.http.impl.conn.PoolingHttpClientConnectionManager - Connection manager is shutting down
2509 [main] DEBUG org.apache.http.impl.conn.DefaultManagedHttpClientConnection - http-outgoing-0: Close connection
2510 [main] DEBUG org.apache.http.impl.conn.PoolingHttpClientConnectionManager - Connection manager shut down
2511 [main] DEBUG com.intuit.logger - Exit HTTPClientConnectionInterceptor.
2511 [main] DEBUG com.intuit.logger - Enter DecompressInterceptor...
2511 [main] DEBUG com.intuit.logger - Decompressed Response Body : <?xml version="1.0" encoding="UTF-8" standalone="yes"?>
<IntuitResponse time="2017-09-20T02:37:07.562-07:00" xmlns="http://schema.intuit.com/finance/v3">
<Fault type="AUTHENTICATION">
<Error code="3200">
<Message>message=AuthenticationFailed; errorCode=003200; statusCode=401</Message>
<Detail></Detail>
</Error>
</Fault>
</IntuitResponse>
2511 [main] DEBUG com.intuit.logger - Exit DecompressInterceptor.
2511 [main] DEBUG com.intuit.logger - Enter DeserializeInterceptor...
2511 [main] INFO com.intuit.logger - HttpResponse content-type (deserialization format) : xml
2512 [main] DEBUG com.intuit.logger - HttpResponse content-type (deserialization format) : xml
3585 [main] DEBUG com.intuit.logger - Exit DeserializeInterceptor.
3585 [main] DEBUG com.intuit.logger - Enter HandleResponseInterceptor...
3586 [main] ERROR com.intuit.logger - Error while calling entity add:: message=AuthenticationFailed; errorCode=003200; statusCode=401
notice that I did the following configurations:
In intuit-config.xml>>
<?xml version="1.0" encoding="UTF-8"?>
<intuit-config>
<baseURL>
<qbo>https://sandbox-quickbooks.api.intuit.com/v3/company</qbo>
</baseURL>
</intuit-config>
In config.properties
I used https://developer.intuit.com/v2/ui#/playground to get this information from.
>
#For OAuth2 app set oauth.type=2
oauth.type=2
#OAuth2 access token
oauth2.accessToken =L011505900548zBbxMrQrmfBnApHFLwR8KslQ7zzVL2fgB0XaJ
#company id or realmId
company.id=193514552765139
#OAuth1 keys
app.token=
consumer.key=
consumer.secret=
oauth.accessToken=
oauth.accessTokenSecret=
Java build : 1.8.0_144
And i have added (ipp-v3-java-data,ipp-v3-java-devkit,oauth2-platform-api) to make the project build successfully

How to Create new project in Rally using RallyRestApi

In the following code I am trying to create a new project using RallyRestApi,
RallyMain {
public static void main(String[] a) {
BasicConfigurator.configure();
try {
RallyRestApi restApi = new RallyRestApi(new URI(
"https://rally1.rallydev.com"), "_APIKey");
restApi.setApplicationName("RallyRestExample");
restApi.setWsapiVersion("v2.0");
JsonObject newProject = new JsonObject();
newProject.addProperty("Name", "Sample Project One");
newProject.addProperty("Description", "Sample project for testing API");
//newProject.addProperty("Owner", "nmuthusamy");
newProject.addProperty("Workspace", "/workspace/Workspace 1");
CreateRequest createRequest = new CreateRequest("Project", newProject);
CreateResponse createResponse = restApi.create(createRequest);
System.out.println("Response "+createResponse.wasSuccessful());
} catch (Exception e) {
System.out.println("Exception \n"+e);
}
}
}
When I run the above code new project was not created on the Rally workspace.System.out.println("Response "+createResponse.wasSuccessful()); always prints false. Here ScreenShot of my rally workspace I have also attached the screen of my Workspace
I have even followed the answer given in this link Stackoverflow but it is not woking.
Following is the console log which I get when I run the main method.
0 [main] DEBUG org.apache.http.impl.conn.BasicClientConnectionManager - Get connection for route {s}->https://rally1.rallydev.com:443
15 [main] DEBUG org.apache.http.impl.conn.DefaultClientConnectionOperator - Connecting to rally1.rallydev.com:443
448 [main] DEBUG org.apache.http.client.protocol.RequestAddCookies - CookieSpec selected: default
449 [main] DEBUG org.apache.http.client.protocol.RequestAuthCache - Auth cache not set in the context
449 [main] DEBUG org.apache.http.client.protocol.RequestTargetAuthentication - Target auth state: UNCHALLENGED
450 [main] DEBUG org.apache.http.client.protocol.RequestProxyAuthentication - Proxy auth state: UNCHALLENGED
450 [main] DEBUG com.rallydev.rest.client.ApiKeyClient - Attempt 1 to execute request
450 [main] DEBUG org.apache.http.impl.conn.DefaultClientConnection - Sending request: POST /slm/webservice/v2.0/project/create.js?fetch=true HTTP/1.1
450 [main] DEBUG org.apache.http.wire - >> "POST /slm/webservice/v2.0/project/create.js?fetch=true HTTP/1.1[\r][\n]"
451 [main] DEBUG org.apache.http.wire - >> "zsessionid: _F99sUCMTR7OsOz4IpiCWp5Xl1UYRJ0wFqBpg5Wz5kFg[\r][\n]"
451 [main] DEBUG org.apache.http.wire - >> "X-RallyIntegrationLibrary: Rally Rest API for Java v2.2.1[\r][\n]"
451 [main] DEBUG org.apache.http.wire - >> "X-RallyIntegrationVersion: 2.2.1[\r][\n]"
451 [main] DEBUG org.apache.http.wire - >> "X-RallyIntegrationName: RallyRestExample[\r][\n]"
451 [main] DEBUG org.apache.http.wire - >> "X-RallyIntegrationVendor: Rally Software, Inc.[\r][\n]"
451 [main] DEBUG org.apache.http.wire - >> "Accept-Encoding: gzip,deflate[\r][\n]"
451 [main] DEBUG org.apache.http.wire - >> "Content-Length: 125[\r][\n]"
451 [main] DEBUG org.apache.http.wire - >> "Content-Type: text/plain; charset=UTF-8[\r][\n]"
451 [main] DEBUG org.apache.http.wire - >> "Host: rally1.rallydev.com[\r][\n]"
451 [main] DEBUG org.apache.http.wire - >> "Connection: Keep-Alive[\r][\n]"
451 [main] DEBUG org.apache.http.wire - >> "User-Agent: Apache-HttpClient/4.5.3 (Java/1.8.0_40)[\r][\n]"
451 [main] DEBUG org.apache.http.wire - >> "[\r][\n]"
452 [main] DEBUG org.apache.http.headers - >> POST /slm/webservice/v2.0/project/create.js?fetch=true HTTP/1.1
452 [main] DEBUG org.apache.http.headers - >> zsessionid: _ApiKey
452 [main] DEBUG org.apache.http.headers - >> X-RallyIntegrationLibrary: Rally Rest API for Java v2.2.1
452 [main] DEBUG org.apache.http.headers - >> X-RallyIntegrationVersion: 2.2.1
452 [main] DEBUG org.apache.http.headers - >> X-RallyIntegrationName: RallyRestExample
452 [main] DEBUG org.apache.http.headers - >> X-RallyIntegrationVendor: Rally Software, Inc.
452 [main] DEBUG org.apache.http.headers - >> Accept-Encoding: gzip,deflate
452 [main] DEBUG org.apache.http.headers - >> Content-Length: 125
452 [main] DEBUG org.apache.http.headers - >> Content-Type: text/plain; charset=UTF-8
452 [main] DEBUG org.apache.http.headers - >> Host: rally1.rallydev.com
452 [main] DEBUG org.apache.http.headers - >> Connection: Keep-Alive
452 [main] DEBUG org.apache.http.headers - >> User-Agent: Apache-HttpClient/4.5.3 (Java/1.8.0_40)
452 [main] DEBUG org.apache.http.wire - >> "{"Project":{"Name":"Sample Project One","Description":"Sample project for testing API","Workspace":"/workspace/Workspace 1"}}"
1719 [main] DEBUG org.apache.http.wire - << "HTTP/1.1 200 OK[\r][\n]"
1720 [main] DEBUG org.apache.http.wire - << "Date: Sat, 10 Jun 2017 07:59:30 GMT[\r][\n]"
1720 [main] DEBUG org.apache.http.wire - << "Content-Type: application/json; charset=utf-8[\r][\n]"
1720 [main] DEBUG org.apache.http.wire - << "Content-Length: 176[\r][\n]"
1720 [main] DEBUG org.apache.http.wire - << "Connection: keep-alive[\r][\n]"
1720 [main] DEBUG org.apache.http.wire - << "Set-Cookie: __cfduid=dc354f67bed2fd443e4bbd5081140f56d1497081569; expires=Sun, 10-Jun-18 07:59:29 GMT; path=/; domain=.rallydev.com; HttpOnly[\r][\n]"
1720 [main] DEBUG org.apache.http.wire - << "X-XSS-Protection: 1; mode=block[\r][\n]"
1720 [main] DEBUG org.apache.http.wire - << "RallyRequestID: qd-app-071j56j3qgdx7xfhnyq78y1yxw7.qd-app-075984713[\r][\n]"
1720 [main] DEBUG org.apache.http.wire - << "Expires: Thu, 01 Jan 1970 00:00:00 GMT[\r][\n]"
1720 [main] DEBUG org.apache.http.wire - << "Set-Cookie: JSESSIONID=qd-app-071j56j3qgdx7xfhnyq78y1yxw7.qd-app-07;Path=/;Secure;HttpOnly[\r][\n]"
1720 [main] DEBUG org.apache.http.wire - << "Set-Cookie: SUBBUCKETID=108;Path=/;Domain=rally1.rallydev.com;Secure;HttpOnly[\r][\n]"
1720 [main] DEBUG org.apache.http.wire - << "Set-Cookie: SUBSCRIPTIONID=122108;Path=/;Domain=rally1.rallydev.com;Secure;HttpOnly[\r][\n]"
1720 [main] DEBUG org.apache.http.wire - << "Vary: Accept-Encoding[\r][\n]"
1720 [main] DEBUG org.apache.http.wire - << "Content-Encoding: gzip[\r][\n]"
1721 [main] DEBUG org.apache.http.wire - << "P3P: CP="NON DSP COR CURa PSAa PSDa OUR NOR BUS PUR COM NAV STA"[\r][\n]"
1721 [main] DEBUG org.apache.http.wire - << "Cache-Control: private,max-age=0,must-revalidate[\r][\n]"
1721 [main] DEBUG org.apache.http.wire - << "Strict-Transport-Security: max-age=31536000; includeSubDomains; preload;[\r][\n]"
1721 [main] DEBUG org.apache.http.wire - << "Set-Cookie: SERVERID=2dd8f75e6436014e8021e4a12eb0016859253e05; path=/[\r][\n]"
1721 [main] DEBUG org.apache.http.wire - << "Server: cloudflare-nginx[\r][\n]"
1721 [main] DEBUG org.apache.http.wire - << "CF-RAY: 36cacaa1dd7c2ee7-DEL[\r][\n]"
1721 [main] DEBUG org.apache.http.wire - << "[\r][\n]"
1722 [main] DEBUG org.apache.http.impl.conn.DefaultClientConnection - Receiving response: HTTP/1.1 200 OK
1722 [main] DEBUG org.apache.http.headers - << HTTP/1.1 200 OK
1722 [main] DEBUG org.apache.http.headers - << Date: Sat, 10 Jun 2017 07:59:30 GMT
1722 [main] DEBUG org.apache.http.headers - << Content-Type: application/json; charset=utf-8
1722 [main] DEBUG org.apache.http.headers - << Content-Length: 176
1722 [main] DEBUG org.apache.http.headers - << Connection: keep-alive
1722 [main] DEBUG org.apache.http.headers - << Set-Cookie: __cfduid=dc354f67bed2fd443e4bbd5081140f56d1497081569; expires=Sun, 10-Jun-18 07:59:29 GMT; path=/; domain=.rallydev.com; HttpOnly
1722 [main] DEBUG org.apache.http.headers - << X-XSS-Protection: 1; mode=block
1722 [main] DEBUG org.apache.http.headers - << RallyRequestID: qd-app-071j56j3qgdx7xfhnyq78y1yxw7.qd-app-075984713
1722 [main] DEBUG org.apache.http.headers - << Expires: Thu, 01 Jan 1970 00:00:00 GMT
1722 [main] DEBUG org.apache.http.headers - << Set-Cookie: JSESSIONID=_jsessionid;Path=/;Secure;HttpOnly
1722 [main] DEBUG org.apache.http.headers - << Set-Cookie: SUBBUCKETID=108;Path=/;Domain=rally1.rallydev.com;Secure;HttpOnly
1722 [main] DEBUG org.apache.http.headers - << Set-Cookie: SUBSCRIPTIONID=122108;Path=/;Domain=rally1.rallydev.com;Secure;HttpOnly
1722 [main] DEBUG org.apache.http.headers - << Vary: Accept-Encoding
1723 [main] DEBUG org.apache.http.headers - << Content-Encoding: gzip
1723 [main] DEBUG org.apache.http.headers - << P3P: CP="NON DSP COR CURa PSAa PSDa OUR NOR BUS PUR COM NAV STA"
1723 [main] DEBUG org.apache.http.headers - << Cache-Control: private,max-age=0,must-revalidate
1723 [main] DEBUG org.apache.http.headers - << Strict-Transport-Security: max-age=31536000; includeSubDomains; preload;
1723 [main] DEBUG org.apache.http.headers - << Set-Cookie: SERVERID=_serverid; path=/
1723 [main] DEBUG org.apache.http.headers - << Server: cloudflare-nginx
1723 [main] DEBUG org.apache.http.headers - << CF-RAY: 36cacaa1dd7c2ee7-DEL
1736 [main] DEBUG org.apache.http.client.protocol.ResponseProcessCookies - Cookie accepted [__cfduid="_cfduid", version:0, domain:rallydev.com, path:/, expiry:Sun Jun 10 13:29:29 IST 2018]
1736 [main] DEBUG org.apache.http.client.protocol.ResponseProcessCookies - Cookie accepted [JSESSIONID="_jsessionid", version:0, domain:rally1.rallydev.com, path:/, expiry:null]
1736 [main] DEBUG org.apache.http.client.protocol.ResponseProcessCookies - Cookie accepted [SUBBUCKETID="108", version:0, domain:rally1.rallydev.com, path:/, expiry:null]
1737 [main] DEBUG org.apache.http.client.protocol.ResponseProcessCookies - Cookie accepted [SUBSCRIPTIONID="999999", version:0, domain:rally1.rallydev.com, path:/, expiry:null]
1737 [main] DEBUG org.apache.http.client.protocol.ResponseProcessCookies - Cookie accepted [SERVERID="_serverid", version:0, domain:rally1.rallydev.com, path:/, expiry:null]
1738 [main] DEBUG com.rallydev.rest.client.ApiKeyClient - Connection can be kept alive indefinitely
1750 [main] DEBUG org.apache.http.wire - << "[0x1f]"
1750 [main] DEBUG org.apache.http.wire - << "[0x8b]"
1750 [main] DEBUG org.apache.http.wire - << "[0x8]"
1750 [main] DEBUG org.apache.http.wire - << "[0x0]"
1750 [main] DEBUG org.apache.http.wire - << "[0x0][0x0][0x0][0x0][0x0][0x3]"
1750 [main] DEBUG org.apache.http.wire - << "M[0xce][0xb1][\n]"
1751 [main] DEBUG org.apache.http.wire - << "[0xc2]#[0xc][0x6][0xe0]W[0x9][0x99][0xa5][0x88]c7[0xa9][0xe][0x1d]D[0xd1][0xa1][0x83]-r[0xb6][0xb1][0xb4][0x1c]I[0xc9][0xdd][\r]R[0xfa][0xee]FEp[0x9][0xe4]#[0xf9][0x93][0x19][0xb]%[0x17][0xe9]L![0xf9][0x88]9[0xcc]xS[0xe7][0xfd]s{*[0xf]n[0x14]5[0xc2][\r][0xae][0xe0][0x8f][0x7][0xfe][0xf2][0xfa][0xcd]{U[0xd1]`[0xed][0x15][0xb]I[0xbe][0x3][0x96][0x8][0x16][0xd9][0xe5]p[0xbc][0x8f][0xd4][0xc6][0xf]<$qgUX[0xee]r[0xe0][0xe4]=6[0x96]Q9[0xe5][0x81][0xfb]oJ[0x19]a[0x8][0xb6][0x4]^[0xb8]'[0x5][0xa6][0x96]Bp[0xfa][0x84]([0xe0][0xa6][0x89],[0xa8][0xc6]l[0xc]5[0xbe][0xa5][0xba][0xd8]Kv0HR[0x1b][0xcc][0xb0]Y[0x96][0x17][0xef][0xff][0xd1]?[0xd5][0x0][0x0][0x0]"
1751 [main] DEBUG org.apache.http.impl.conn.BasicClientConnectionManager - Releasing connection org.apache.http.impl.conn.ManagedClientConnectionImpl#23986957
1751 [main] DEBUG org.apache.http.impl.conn.BasicClientConnectionManager - Connection can be kept alive indefinitely
Response false
Thanks,
Nithyananth
Check out the errors in your response. The fact that wasSuccessful returns false means there were problems with your create.
String errors = createResponse.getErrors();
System.out.println(errors[0]);
One problem is that your workspace reference is by name- they need to be by ref (which is of the format /[type]/[objectid])
newProject.addProperty("Workspace", "/workspace/12345");

Categories

Resources