I am trying to send a test order in to test the HMAC signature generation but I am getting the following error back from the API
org.springframework.web.client.HttpClientErrorException$Unauthorized: 401 Unauthorized: [no body]
Below is the Java code I am using to call the REST API
public ResponseEntity<String> testOrder() {
Date date = new Date();
StringBuilder url = new StringBuilder();
url.append(BINANCE_API_BASE_URL)
.append("/")
.append(BINANCE_API_VERSION)
.append("/")
.append("order")
.append("/")
.append("test");
HttpHeaders headers = new HttpHeaders();
String body = "symbol=BTCUSD×tamp=" + date.getTime();
byte[] hmac = HMAC.calcHmacSha256(apiKeysConfiguration.getSecretKey().getBytes(StandardCharsets.UTF_8), body.getBytes(StandardCharsets.UTF_8));
String signature = String.format("%032x", new BigInteger(1, hmac));
body = body + "&signature=" + signature;
System.out.println(body);
HttpEntity<String> entity = new HttpEntity<>(body, headers);
return restTemplate.exchange(url.toString(), POST, entity, String.class);
}