batchorders err 400 null

[{symbol: “ETHUSDT”, side: “SELL”, quantity: 0.01, price: 1317.15, type: “LIMIT”},
{symbol: “ETHUSDT”, side: “SELL”, quantity: 0.007, price: 1310.85, type: “LIMIT”},
{symbol: “ETHUSDT”, side: “SELL”, quantity: 0.008, price: 1304.55, type: “LIMIT”},
{symbol: “ETHUSDT”, side: “SELL”, quantity: 0.017, price: 1298.24, type: “LIMIT”},
{symbol: “ETHUSDT”, side: “SELL”, quantity: 0.009, price: 1291.94, type: “LIMIT”}]

Hi can someone let me know what is wrong with this batch order? Its saying
0: {code: 400, msg: null}
1: {code: 400, msg: null}
2: {code: 400, msg: null}
3: {code: 400, msg: null}
4: {code: 400, msg: null}

Please share your whole request; It’s possible you didn’t encode your request

I did that was the previous problem because was getting signature failure and then encoded batch and went through but said forgot to add type so I added type limit and then got this and was thinking had something to do with amount of decimals I had on quantity and price so made those smaller. I think its sending fine just something wrong with my batchOrders value but yeah.

https://fapi.binance.com/fapi/v1/batchOrders?timestamp=1611251247965&batchOrders=[{"symbol"%3A"ETHUSDT"%2C"side"%3A"SELL"%2C"quantity"%3A0.012%2C"type"%3A"LIMIT"%2C"price"%3A1250.7}%2C{"symbol"%3A"ETHUSDT"%2C"side"%3A"SELL"%2C"quantity"%3A0.011%2C"type"%3A"LIMIT"%2C"price"%3A1244.71}%2C{"symbol"%3A"ETHUSDT"%2C"side"%3A"SELL"%2C"quantity"%3A0.007%2C"type"%3A"LIMIT"%2C"price"%3A1238.73}%2C{"symbol"%3A"ETHUSDT"%2C"side"%3A"SELL"%2C"quantity"%3A0.018%2C"type"%3A"LIMIT"%2C"price"%3A1232.75}%2C{"symbol"%3A"ETHUSDT"%2C"side"%3A"SELL"%2C"quantity"%3A0.008%2C"type"%3A"LIMIT"%2C"price"%3A1214.79}]&signature=9718a5e2a4fe4700b36dykf5ce6fe375357454f5fb7c8j5a6609739d4b6f2ebc

[{“symbol”:“ETHUSDT”,“side”:“SELL”,“quantity”:0.012,“type”:“LIMIT”,“price”:1250.7},{“symbol”:“ETHUSDT”,“side”:“SELL”,“quantity”:0.011,“type”:“LIMIT”,“price”:1244.71},{“symbol”:“ETHUSDT”,“side”:“SELL”,“quantity”:0.007,“type”:“LIMIT”,“price”:1238.73},{“symbol”:“ETHUSDT”,“side”:“SELL”,“quantity”:0.018,“type”:“LIMIT”,“price”:1232.75},{“symbol”:“ETHUSDT”,“side”:“SELL”,“quantity”:0.008,“type”:“LIMIT”,“price”:1214.79}]

and to encode batchOrders doing
encodeURIComponent(JSON.stringify(batchOrders))

I think its something weird with the way its encode and I need to figure out a way to use the correct replacements for encoding it in my own js function

Youre correct had to add timeinforce and then instead of using that encode function i just. made my own little js function to add the % characters in place of " and { and } and worked. Thanks!

I’m lost with this problem as well. Can you share the final correct url? How is the batchOrders url encoded correctly?

I had the same issue(s) with this specific endpoint. I have managed to make it work by doing the following:

  1. I prepare the url https://testnet.binancefuture.com/fapi/v1/batchOrders by adding the timestamp parameter
  2. I take the json array of order requests and convert it to string like so:

[{“symbol”:“ETHUSDT”,“side”:“SELL”,“quantity”:0.012,“type”:“LIMIT”,“price”:1250.7},{“symbol”:“ETHUSDT”,“side”:“SELL”,“quantity”:0.011,“type”:“LIMIT”,“price”:1244.71},{“symbol”:“ETHUSDT”,“side”:“SELL”,“quantity”:0.007,“type”:“LIMIT”,“price”:1238.73},{“symbol”:“ETHUSDT”,“side”:“SELL”,“quantity”:0.018,“type”:“LIMIT”,“price”:1232.75},{“symbol”:“ETHUSDT”,“side”:“SELL”,“quantity”:0.008,“type”:“LIMIT”,“price”:1214.79}]

  1. I manually encode the jsonString using the following rules:
    jsonString.replace(""", “%22”)
    .replace("{","%7B")
    .replace("}","%7D")
    .replace(":","%3A")
    .replace("[","%5B")
    .replace("]","%5D")
    .replace(",","%2C");
  2. I add the encoded json to the url as batchOrders=[encoded json]
  3. I generate the signature on the urlParams and add it to the url as signature=[signature]
  4. I make the request

This mostly works but I do get the occasional bad gateway error which is concerning to be honest

  1. Your double quotes seem odd to me. Please make sure they’re input from standard English input method
  2. Need to add “timeInForce”:“GTC” for each order