0

I got a problem in vba while trying to interact with GDAX API.

I get this error: {"message":"Requires product_id"}

I cant pass my product_id in the orders "POST" in WinHttp.WinHttpRequest.5.1 Nothing seems to work:

I tried adding ?product_id=BTC-EUR after the URL as Methodoptions(this works for GET Statements) i tried adding "product_id=BTC-EUR" after the send I tried using JsonString = "{""size"": ""0.01"",""price"": ""0.100"",""side"": ""buy"",""product_id"": ""BTC-USD""}" this as postdata

Does anyone know, how to pass those arguments?

This is the code im working with, that works well for all other authenticated statements not passing parameters.

TradeApiSite = "https://api-public.sandbox.gdax.com"

SignMsg = NonceUnique & UCase(HTTPMethod) & "/" & Method & MethodOptions
APIsign = Base64Encode(ComputeHash_C("SHA256", SignMsg, Base64Decode(secretkey), "RAW"))

' Instantiate a WinHttpRequest object and open it
Set objHTTP = CreateObject("WinHttp.WinHttpRequest.5.1")
objHTTP.Open UCase(HTTPMethod), TradeApiSite & "/" & Method & MethodOptions, False
objHTTP.setRequestHeader "User-Agent", "Mozilla/4.0 (compatible; MSIE 6.0; Windows NT 5.0)"
objHTTP.setRequestHeader "Content-Type", "application/x-www-form-urlencoded"
objHTTP.setRequestHeader "CB-ACCESS-KEY", apikey
objHTTP.setRequestHeader "CB-ACCESS-SIGN", APIsign
objHTTP.setRequestHeader "CB-ACCESS-TIMESTAMP", NonceUnique
objHTTP.setRequestHeader "CB-ACCESS-PASSPHRASE", passphrase

objHTTP.Send '(postdata)
Eggator
  • 11
  • 2
  • Here's an idea: read the documentation from the company who makes it? It probably would have taken you less time than writing that question. – ashleedawg Mar 24 '18 at 15:05
  • actually if you post your key so I can connect to the api then I might be able to figure it out. – ashleedawg Mar 24 '18 at 15:14
  • I'm having the same problem using unirest with java. What I really don't understand is that - looking at the python library I was using before - it doesn't do anything we 're not doing --> https://github.com/danpaquin/gdax-python/blob/master/gdax/authenticated_client.py – MercilessMaverick Mar 24 '18 at 23:25

1 Answers1

0

Figured it out after look a bit deeper at how danpaquin/gdax-python does authentication over here https://github.com/danpaquin/gdax-python/blob/master/gdax/gdax_auth.py

  1. You want to send the JSON string as the post data like you described
  2. Content-Type header should be set to application/json
  3. The post data needs to appended to the pre-hash (in your case SignMsg)

Step 2 is important because with out it, GDAX doesn't seem to read your post data - so you get Requires product_id error. If you do step 2 without step 3, you will get invalid signature error