bitforexapi / API_Doc_en

BitForex API Document
12 stars 9 forks source link

SignData Invalid - Javascript placeOrder #10

Open zdman135 opened 5 years ago

zdman135 commented 5 years ago

Hi,

I am trying to use the endpoint - https://api.bitforex.com/api/v1/trade/placeOrder And I do not know what I am doing wrong. I keep getting the following error:

{ code: '1016',
  success: false,
  time: 1554439494501,
  message: 'SignData Invalid' }

But everything looks right, I even double checked my code to ensure the SignData hash is correct based on the example that was given in the API docs.

Anyone got any ideas?

Here's the code:

var crypto = require('crypto')
var axios = require('axios');
var querystring = require('querystring');

var accessKey = 'xxx'
var secretKey = 'secretxxx'

var amount = "1"
var nonce = (new Date).getTime().toString();
var price = "0.00015393"
var symbol = "coin-eth-bf"
var tradeType = "1"

var message = `/api/v1/trade/placeOrder?accessKey=${accessKey}&amount=${amount}&nonce=${nonce}price=${price}&symbol=${symbol}&tradeType=${tradeType}`;
var hash = crypto.createHmac('sha256', secretKey).update(encodeURI(message));
var signData = hash.digest('hex');

var url_a= 'https://api.bitforex.com/api/v1/trade/placeOrder';

const data = {
    accessKey: accessKey,
    amount: amount,
    nonce: nonce,
    price: price,
    symbol: symbol,
    signData: signData,
    tradeType:tradeType
 };

const options = {
  method: 'POST',
  headers: { 'content-type': 'application/x-www-form-urlencoded' },
  data: encodeURI(querystring.stringify(data)),
  url: url_a
};
axios(options).then(function (response) {
    console.log(response.data);
    })
    .catch(function (error) {
    console.log(error);
    });
MarvinBaral commented 5 years ago

Sorry for the late reply. I think signData is always the last parameter in the request, it is not alphabetically sorted like the others.

dinastyoffreedom commented 4 years ago

I set SignData like last parameter but the same SignData invalid code 1016

api/v1/trade/placeOrder?accessKey=xxxxxx&amount=0.005&nonce=1569660263141&price=8205.09&symbol=coin-usdt-btc&tradeType=1&signData=xxxxxxxx

signature is correct when I access to "/api/v1/fund/mainAccount" POST /api/v1/fund/mainAccount?accessKey=xxxxxxxxxxxx&currency=btc&nonce=1569660907228&signData=xxxxxxxx

BronacusAmmon commented 4 years ago

Did you ever get this solved? I'm having the exact same problem, down to the working correctly when checking balances of a coin in the /api/v1/fund/mainAccount

panique commented 2 years ago

Same here

MrSaltanyuk commented 2 years ago

Still the same problem. I do it with python, but I can't imagine, whats wrong