- Controller
@PostMapping("/v1/orders")
@Operation(summary = "주문하기", description = "화폐 주문")
public ResponseEntity<OrderResponse> orderCoin() throws UnsupportedEncodingException, NoSuchAlgorithmException {
System.out.println("주문하기");
return ResponseEntity.ok(tradingService.orderCoin());
}
- Serivce
public OrderResponse orderCoin() throws UnsupportedEncodingException, NoSuchAlgorithmException {
String side = "bid";
String price = "10000";
String volume = "";
String ord_type = side.equals("bid") ? "price" : "market";
HashMap<String, String> params = new HashMap<>();
params.put("market", "KRW-ETH");
params.put("side", side);
params.put("price", price);
params.put("ord_type", ord_type);
String orderUrl = serverUrl + "/v1/orders";
HttpHeaders headers = new HttpHeaders();
headers.set("Content-Type", "application/json");
headers.set("Authorization", jwtTokenProvider.createOrderToken(params));
HttpEntity<String> entity = new HttpEntity<>(new Gson().toJson(params), headers);
return restTemplate.exchange(
orderUrl,
HttpMethod.POST,
entity,
new ParameterizedTypeReference<OrderResponse>() {
}).getBody();
}
HttpRequestMethodNotSupportedException: Request method 'GET' is not supported
-> POST 요청을 보냈으나 GET 요청이 불가하다는 오류
- Controller단에서 print로 확인 해보았으나 Controller에도 도달하지 못하는 상황
- API테스트를 어플리케이션 실행 후 localhost 웹 페이지에 접속해서 url을 통해 진행
- 일반적인 url은 GET방식이기에 위와같은 오류가 발생
- Postman을 통한 테스트 시 정상 작동 확인