Binance Coin
$5.06 9.60%
BNB · 27w

API 404 when using Java

Hello there. I'm having an issue where I can pull account data from Binance with curl, but not using an equivalent Java implementation. Curl: MILLIS=$(date +%s%3N) # -> 1528099834650 KEY="***" SECRET="***" SIGNATURE=$(echo -n "timestamp=$MILLIS" | openssl dgst -sha256 -hmac $SECRET | cut -c 10-) # -> df1e59b1fce4540905210c72d7ba49a057b384ab789db13ca7d1e161c0c74109 BASE="https://api.binance.com/api/v3/" METHOD="account" echo $BASE$METHOD'?timestamp='$MILLIS'&signature='$SIGNATURE` curl -H "X-MBX-APIKEY: "$KEY -X GET $BASE$METHOD'?timestamp='$MILLIS'&signature='$SIGNATURE This returns proper JSON\-data. However, the following Java implementation returns a "Bad request exception" \(HTTP 400\). Java: final String nonce = String.valueOf(System.currentTimeMillis()); // -> 1528101026288 String reqString = "timestamp=" + nonce; String signature = sha256_B64(reqString); // -> HmacSHA256 with Base64 encoding using private key (secret) // -> 6dec21ad300b691605cb915854685acdc8e5e77231587fd7dca58dba6e789391 final String urlMethod = "https://api.binance.com/api/" + "v3/account"; String finalUrl = urlMethod + "?" + reqString + "&signature=" + signature; final HttpsURLConnection httpsConn = (HttpsURLConnection)new URL(finalUrl).openConnection(); httpsConn.setRequestMethod("GET"); httpsConn.setRequestProperty("X-MBX-APIKEY", publicKey); in = new BufferedReader(new InputStreamReader(httpsConn.getInputStream())); String inputLine; StringBuilder response = new StringBuilder(); while ((inputLine = in.readLine()) != null) { response.append(inputLine); } return response.toString(); Both methods are calling valid URLs. I have already verified that my working curl implementation returns identical signatures compared to the java\-generated ones. Curl: `https://api.binance.com/api/v3/account?timestam...
Continue on self.BinanceExchange
Recent news
BNB +9.60% · ccn.com · 9h

NYDFS Hastens Response to BitLicense Applications

According to data obtained from the source – the New York Department of Financial Services itself – the financial regulator has only responded to 9 of 36 BitLicense applications submitted since 2015. ...