DELETE /fapi/v1/batchOrders endpoint error with signature ?!

Hello everyone,
I hope you’re all doing well. I’m facing an issue while trying to cancel some open orders when using DELETE /fapi/v1/batchOrders endpoint.
This error return:

{ code: -1022, msg: 'Signature for this request is not valid.' }

If i use ‘DELETE /fapi/v1/order’ endpoint, it worked, no error with Signature. But DELETE /fapi/v1/batchOrders is not working.
Any problem in my code ?
Thank in advanced !
This is my code:

const symbol = dataToCancel.symbol;
                      const origClientOrderIdList = dataToCancel.origClientOrderIdList;

                      const params = {
                        symbol: symbol,
                        origClientOrderIdList: origClientOrderIdList,
                        timestamp: Date.now()
                      }
                      queryString = Object.keys(params)
                      .map((key) => `${key}=${params[key]}`)
                      .join('&');
                      signature = crypto
                      .createHmac('sha256', secretKey)
                      .update(queryString)
                      .digest('hex');
                      console.log(signature);

                      params.signature = signature;
                      await axios.delete(`${BASE_URL}/fapi/v1/batchOrders`, {
                        headers: headers,
                        params: params  
                      })
                      .then(async (response) =>{
                        console.log(response);
                      })
                      .catch(error => {
                        console.error(`Error get position and open orders 1:`, error.response.data);
                      })

Please find this example python code for how to do batch orders, hopefully it will be helpful.

1 Like

Since the previous answer is in python, here’s how I do it in my SDK for binance, also in node.js with axios under the hood:

The SDK is also on npm if you wish to use it directly as is. Key thing is to stringify the order ID list before you build the request.