GDAX api request returning error 400 "BadRequest"

738 views Asked by At

I'm trying to place an order using the GDAX api endpoints but keep getting a status 400 code with the only description "BadRequest".

parameters are below:

httpMethod is: "POST"

endpoint is: https://api.gdax.com/orders

JSON body is: { "product_id": BTC-USD, "stp": cn, "cancel_after": min, "post_only": 1, "time_in_force": GTC, "size": 1e-06, "side": buy, "type": limit, "price": 1000.01, "client_oid": e7CS7ju58TyH83HScLZnX+wdm8dMAMvZ93bGIlkP1Y= }

I've verified auth is working and the api is correctly handling other private requests such as returning account information but both market and limit orders are returning the 400 "BadRequest" error. Has anyone encountered this before? I've checked and double checked all the account information is correct and returning the proper information but still don't know what else could be causing this.

2

There are 2 answers

2
Max On

I ran into this earlier today and I think it's that GDAX is picky about the client_oid field (conveniently, poorly documented). To test, you can just leave it off and see if that works, but for me, I ended up having to use exactly UUID.randomUUID() (Java) without prefixing it or anything. It generates a random hexadecimal string containing a few -s.

I don't know what programming language you're using, but hopefully this is at least a pointer in the right direction.

0
Manos Kouvarakis On

I was having the same issue for c# code. The problem was that I haven't added the User Agent header. When I did, everything works perfect

HttpClient gdaxClient = new HttpClient();
gdaxClient.DefaultRequestHeaders.Add("User-Agent", ".NET Framework Test Client");