Bitstamp API:始终接收API0000(缺少密钥,签名和nonce参数。)

时间:2018-05-26 08:36:41

标签: java rest api feign

研究这个SO问题(Authenticated Java Jersey REST call to Bitstamp),我发现OP有类似的问题。不幸的是,我无法在我自己的实现中调用调用:我尝试通过查询参数以及请求主体中格式化的json发送keynoncesignature。我记录了标题和内容,因此在这两种情况下,这些是生成的日志:

// send in body
---> POST https://www.bitstamp.net/api/v2/balance/ HTTP/1.1
Accept: application/json;charset=UTF-8
Content-Type: application/json;charset=UTF-8
Content-Length: 140

{"key":"12345678901234567890123456789012","nonce":1234567890,"signature":"1234567890123456789012345678901234567890123456789012345678901234"}
---> END HTTP (140-byte body)
<--- HTTP/1.1 403 Authentication Failed (49ms)
{"status": "error", "reason": "Missing key, signature and nonce parameters.", "code": "API0000"}
<--- END HTTP (96-byte body)


// send as query-parameters
---> POST https://www.bitstamp.net/api/v2/balance/?key=12345678901234567890123456789012&signature=1234567890123456789012345678901234567890123456789012345678901234&nonce=1234567890 HTTP/1.1
Accept: application/json;charset=UTF-8
Content-Type: application/x-www-form-urlencoded
---> END HTTP (0-byte body)
<--- HTTP/1.1 403 Authentication Failed (45ms)
{"status": "error", "reason": "Missing key, signature and nonce parameters.", "code": "API0000"}
<--- END HTTP (96-byte body)

我做错了什么? bitstamp在声明

时的含义是什么
  

要成功进行身份验证,您需要提供API密钥,签名和nonce参数。   (https://www.bitstamp.net/api/

我使用Feign作为REST客户端。这两种方法看起来像这样:

@PostMapping(value = "api/v2/balance/", produces = MediaType.APPLICATION_JSON_UTF8_VALUE, consumes = MediaType.APPLICATION_FORM_URLENCODED_VALUE)
ResponseEntity<Map<String, Object>> getAccountBalanceQuery(@RequestParam("key") String key,
                                                      @RequestParam("signature") String signature,
                                                      @RequestParam("nonce") Integer nonce);

@PostMapping(value = "api/v2/balance/", produces = MediaType.APPLICATION_JSON_UTF8_VALUE, consumes = MediaType.APPLICATION_JSON_UTF8_VALUE)
ResponseEntity<Map<String, Object>> getAccountBalanceBody(@RequestBody BitstampAuth body);

谢谢!

0 个答案:

没有答案