I’m having bother with a (400) dangerous request on POST requests. I’m able to execute all Get and Delete requests with the identical signature course of, however clearly the physique is string.empty. We’ve got examined all types of various JSON formatting to attempt to get this to work, however it isn’t working. We’ve got not been capable of finding an instance of ANY prehash signature to match to. Additionally, except the POST server time is totally different than the GET and DELETE server occasions we have now the proper timestamp as we’re inside 1 second of the GET/time API name for server time. GDAX permits for 30 second buffer to authenticate.
Public Shared Perform placeOrder()
Attempt
Dim Physique As String = "{""sort"":""restrict"",""aspect"":""promote"",""product_id"":""BTC-USD"",""value"":""20000"",""dimension"":""0.02235229""}"
Dim ts As String = GetNonce()
Dim methodology As String = "/orders"
Dim str_GDAX_Main As String = "https://api.gdax.com"
Dim sig As String = GetSignature(ts, "POST", methodology, Physique)
Dim fr As System.Web.HttpWebRequest
Dim targetURI As New Uri(str_GDAX_Main & methodology)
'Dim response As String
Dim jsonDataBytes As Byte() = Encoding.UTF8.GetBytes(Physique)
fr = DirectCast(HttpWebRequest.Create(targetURI), System.Web.HttpWebRequest)
fr.Headers.Add("CB-ACCESS-KEY", config_API_Key)
fr.Headers.Add("CB-ACCESS-SIGN", sig)
fr.Headers.Add("CB-ACCESS-TIMESTAMP", ts)
fr.Headers.Add("CB-ACCESS-PASSPHRASE", config_API_Passphrase)
fr.UserAgent = UserAgent
fr.Settle for = "software/json"
fr.Technique = "POST"
fr.ContentLength = jsonDataBytes.Size
Dim stream = fr.GetRequestStream()
stream.Write(jsonDataBytes, 0, jsonDataBytes.Size)
stream.Shut()
Dim response = fr.GetResponse().GetResponseStream()
Dim reader As New StreamReader(response)
Dim res = reader.ReadToEnd()
reader.Shut()
response.Shut()
Return res
'If (fr.GetResponse().ContentLength > 0) Then
' Dim str As New System.IO.StreamReader(fr.GetResponse().GetResponseStream())
' response = (str.ReadToEnd())
' str.Shut()
'Finish If
'Form1.RichTextBox1.Textual content = (response)
Catch ex As System.Web.WebException
MessageBox.Present(ex.Message)
'Error in accessing the useful resource, deal with it
Finish Attempt
Finish Perform
Public Shared Perform GetNonce() As String
Return (DateTime.UtcNow - New DateTime(1970, 1, 1, 0, 0, 0)).TotalSeconds.ToString()
Finish Perform
Public Shared Perform GetSignature(nonce As String, methodology As String, url As String, physique As String) As String
Dim message As String = String.Concat(nonce, methodology.ToUpper(), url, physique)
Dim encoding = New ASCIIEncoding()
Dim keyByte As Byte() = Convert.FromBase64String(config_API_Secret)
Dim messageBytes As Byte() = encoding.GetBytes(message)
Utilizing hmacsha256 = New HMACSHA256(keyByte)
Dim hashmessage As Byte() = hmacsha256.ComputeHash(messageBytes)
Return Convert.ToBase64String(hashmessage)
Finish Utilizing
Finish Perform
We do not know if our physique is wrong or if the URI is wrong or what the issue is. If somebody can check out it and determine the place our physique syntax error is. Or if we must always look elsewhere.