首页 文章

(JAVA)向Binance交换错误发送http请求

提问于
浏览
0

我现在正在研究从Binance获取加密货币的当前价格 .

我推荐这个API-DOCS(https://github.com/binance-exchange/binance-official-api-docs/blob/master/rest-api.md),"symbol order book ticker"

但是,我的代码显示了一些错误响应,如下所示

'HTTP/1.1 404 Not Found'

<html><body><h2>404 Not found</h2></body></html>

我的代码如下所示

public static void bid_ask () throws ClientProtocolException, IOException {
    String queryArgs = "https://api.binance.com/api/v3/ticker/bookTicker";
    CloseableHttpClient httpClient = HttpClients.createDefault();
    HttpPost post = new HttpPost(queryArgs);

    CloseableHttpResponse response = httpClient.execute(post);
    HttpEntity responseEntity = response.getEntity();
    System.out.println(response.getStatusLine());
    System.out.println(EntityUtils.toString(responseEntity));

}

1 回答

  • 1

    根据您链接的API文档,该URL仅支持GET请求,但您正在发出POST请求 .

相关问题