New order demands orderId?

Hello!

I’ve been using the Binance API for awhile now for testing purposes, but I’m ready to release my algorithm into the world and have it buy and sell for me. What I am doing is creating my own system that decides when to buy or sell at any given time using just the “Buy” and “Sell” features of the API. I will add things like stoplosses later on.

ANYWAYS, the issue I’m having is regarding the following endpoint:
api.binance.com/api/v3/order

I need to buy or sell a stock when my algorithm decides the time is right. HOWEVER, as the following message will show, I keep getting “origClientOrderId or orderId must be set, but both were empty/null”. I do not know why this would be happening, especially since I am creating a new order. How can I give it “orderId” if it’s a new order and hence don’t have an ID yet? I’ve tried applying my own random ID to see if maybe it wants me to give it an ID I can access it through later? But alas to no effect.

The message from my code:
TRYING ENDPOINT: /api/v3/order?symbol=ETHBTC&timestamp=1618367129046&signature=EDITED OUT FOR SECURITY WHILE WRITING THIS TOPIC
RESPONSE: {“code”:-1102,“msg”:“Param ‘origClientOrderId’ or ‘orderId’ must be sent, but both were empty/null!”}

I’ve also tried adding in the extra arguments, but I just get this from my code:
“TRYING ENDPOINT: /api/v3/order?symbol=ETHBTC&side=BUY&type=MARKET&quoteOrderQty=1&timestamp=1618366963305&signature=EDITED OUT FOR SECURITY WHILE WRITING THIS TOPIC
RESPONSE: {“code”:-1104,“msg”:“Not all sent parameters were read; read ‘3’ parameter(s) but was sent ‘6’.”}”.

I’ve followed the API documentation and don’t know what I could have messed up. It seems all ok: https://github.com/binance/binance-spot-api-docs/blob/master/rest-api.md#new-order--trade

I do notice that while “newClientOrderId” says not mandatory, it also says that if I don’t supply it, the API serverside should automatically generate one for me. Maybe it’s just not doing that for some reason? But it doesn’t say anything at all about “orderId”

I’d love to hear any advice anyone would have regarding this problem.

Thanking you in advance,
Techmo

@Chai THANKYOU!!! I completely forgot that my code defaults everything to a “GET” request! Now that I’ve switched it to “POST”, I get a filter error, but I can work with that. Thankyou so much, I never would have solved it without you. Have a wonderful day/night!

Ensure that you are doing a POST request and not a GET request.

1 Like