U
U
U_n_d_e_r2021-05-02 19:47:43
API
U_n_d_e_r, 2021-05-02 19:47:43

How to make a SHA256 api request on Binance?

api request to Binance sending HMAC SHA256
There is a code for obtaining a signature for a similar link .
Signature acquisition code

public static void CreateSignature()
            {
                string queryString = "timestamp=1619967111755";
                string secret = ""; 
                byte[] keyBytes = Encoding.UTF8.GetBytes(secret);
                byte[] queryStringBytes = Encoding.UTF8.GetBytes(queryString);
                HMACSHA256 hmacsha256 = new HMACSHA256(keyBytes);
                byte[] bytes = hmacsha256.ComputeHash(queryStringBytes);
                Console.WriteLine(BitConverter.ToString(bytes).Replace("-", "").ToLower());
        
            }

When you try to send a request, the site responds. {"code":-2014,"msg":"API-key format invalid."}
I tried a bunch of options, it still gives a similar error.

Answer the question

In order to leave comments, you need to log in

1 answer(s)
T
twobomb, 2021-05-02
@twobomb

Well, it says right there.


API-keys are passed into the Rest API via the X-MBX-APIKEY header.

That is, through the X-MBX-APIKEY header, you need to pass the api key
. Even an example of a curl is given
curl -H "X-MBX-APIKEY: vmPUZE6mv9SD5VNHk4HlWFsOr6aKE2zvsw0MuIgwCIPy6utIco14y7Ju91duEh8A" -X POST 'https://api.binance.com/api/v3/order?symbol=LTCBTC&side=BUY&type=LIMIT&timeInForce=GTC&quantity=1&price=0.1&recvWindow=5000&timestamp=1499827319559&signature=c8db56825ae71d6d79447849e617115f4a920fa2acdcab2b053c4b2838bd6b71'

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question