当我尝试发出请求时,出现以下错误消息:
code: -1022, Signature for this request is not valid
正在向https://api.binance.com/sapi/v1/capital/address发送请求。使用时间戳参数时没有错误。但是,使用coin参数或任何其他参数会导致错误。
String path = '/sapi/v1/capital/deposit/address?';
String coin = 'coin=BTC';
int timeStamp = DateTime.now().millisecondsSinceEpoch;
String queryParams = '&recvWindow=60000' + '×tamp=' + timeStamp.toString();
String secret = 'secret key';
List<int> messageBytes = utf8.encode(queryParams);
List<int> key = utf8.encode(secret);
Hmac hmac = new Hmac(sha256, key);
Digest digest = hmac.convert(messageBytes);
String signature = hex.encode(digest.bytes);
String url = baseUrl + path + queryParams + "&signature=" + signature;
void _fetchPosts() async {
final response = await http.get(url, headers: {
"Accept": "application/json",
"X-MBX-APIKEY":
"API-KEY"
});```