Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
493 views
in Technique[技术] by (71.8m points)

node.js - Binance - Mandatory parameter 'type' was not sent, was empty/null, or malformed

I am trying to make a request to the Binance API using the universal transfer call that requires 3 params: "asset", "value" and "type". However, when I make the call with the required params I get the following response:

{
  code: -1102,
  msg: "Mandatory parameter 'type' was not sent, was empty/null, or malformed."
}

I can see that the parameter is being parsed in when I console.log but I still get the error:

[Object: null prototype] {
  code: -1102,
  msg: "Mandatory parameter 'type' was not sent, was empty/null, or malformed."
}

Here's the futuresTransferAsset() function I'm using the API from here

futuresTransferAsset: async ( asset, amount, type ) => {
    let params = Object.assign( { asset, amount, type } );
    return promiseRequest( 'v1/futures/transfer', params, { base:sapi, type:'SIGNED', method:'POST' } );
},

Here is the request:

const result = await binance.futuresTransferAsset('USDT', 1.00, 'UMFUTURE_MAIN')

Am I not parsing in the type param correctly?


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Answer

0 votes
by (71.8m points)

hum! you're trying to build an Object in the line:

let params = Object.assign( { asset, amount, type } );

So you're passing three parameters to futureTransferAsset() function. This line says that:

futuresTransferAsset('USDT', 1.00, 'UMFUTURE_MAIN')

Check what happens when you tried to build an Object replacing the input params.

enter image description here

The "malformed" message could be related with a wrong definition of Object creating in params var definition.

This an example to define an Object:

enter image description here

*assetKeyName, *amountKeyName and *typeKeyName are a supposed key name as best practice of Object type definition.

In conclusion:

  • There is a bad-definition of Object when tried to create params var.
  • params var is passing in promiseRequest with a 'malformed' format or missing-format Object.
  • May be you're missing the key names.
  • This a question: Does the binance api allows receive Object type without key-pair format.

Please let know if I'm missing something.


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...