Cancel Multiple Orders Future API

Hi,

I am trying to cancel multiple orders and I am sending the following:
{‘data’: [(‘orderIdList’, ‘[422691743,422691757]’), (‘symbol’, ‘BNBUSDT’), (‘timestamp’, ‘1599469813176’), (‘signature’, mysignature)], ‘timeout’: 10}
to the url https://fapi.binance.com/fapi/v1/batchOrders.
I am getting the error BinanceAPIException: APIError(code=-1022): Signature for this request is not valid.
The thing is that sending to https://fapi.binance.com/fapi/v1/allOpenOrders works perfectly and so does cancel one single order. So I do not get what issue…

Please check this script, which works fine with batchOrders

thanks

Hi @Nicolas_REY, I was the same problem, after some tries, I found that is necessary encoded the orderIdList, example below:

    def close_multiple_orders(self, symbol, orders):
        responses = []

        chunk_size = 10
        chunked_orders = [
            orders[i * chunk_size:(i + 1) * chunk_size] for i in range((len(orders) + chunk_size - 1) // chunk_size)]

        for current_chunk in chunked_orders:
            serialize_to_string = "[{}]".format(','.join(map(str, current_chunk)))
            order_id_list_encoded = urllib.parse.urlencode({'value': serialize_to_string}).replace('value=', '')

            params = {
                'symbol': symbol,
                'orderIdList': order_id_list_encoded,
            }

           responses.append(self.client.futures_cancel_orders(**params))

        flatten_response = [item for sublist in responses for item in sublist]
        return flatten_response