Skip to content

SignData Invalid - Javascript placeOrder #10

Open

Description

@zdman135

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


Activity

  1. MarvinBaral commented on Apr 24, 2019

    @MarvinBaral

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

  2. dinastyoffreedom commented on Sep 28, 2019

    @dinastyoffreedom

    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

  3. BronacusAmmon commented on Mar 22, 2020

    @BronacusAmmon

    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

  4. panique commented on Nov 2, 2021

    @panique

    Same here

  5. MrSaltanyuk commented on Dec 9, 2021

    @MrSaltanyuk

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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions