0

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.

AnthonyZ
  • 81
  • 4

2 Answers2

1

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.

Max
  • 4,882
  • 2
  • 29
  • 43
  • Any info on what the requirements are for the client ID field? – Kevin Jan 13 '18 at 23:02
  • Not sure, but I think it should look basically the same as the `order_id` that GDAX provides. I also found a couple examples here: https://github.com/coinbase/gdax-node/issues/141 Sorry I don't have better info for you. – Max Jan 14 '18 at 01:26
1

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");