marmule
November 27, 2020, 3:09pm
1
Hello,
I try POSTMAN to use BINANCE API.
When i use an environnement variable in a request for “quantity” parameter, i have a code error : -1022.
POSTMAN genere the following code :
fetch(“https://testnet.binancefuture.com/fapi/v1/order?symbol=BTCUSDT&side=BUY&type=MARKET&quantity=15.8270×tamp=1606488994076&signature=xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx ”, requestOptions)
.then(response => response.text())*
.then(result => console.log(result))*
.catch(error => console.log(‘error’, error));*
MJW
November 27, 2020, 9:40pm
2
You cannot directly quote environment var in parameters; If you really have to use env var, please process it in pre-request script;
Meanwhile fetch() doesn’t work for creating orders
marmule
November 27, 2020, 10:23pm
3
Thank you.
The variable “quantity” is created in pre-post.
postman.setEnvironmentVariable (“quantity”, quantity);
however the variables “signature” and “timestam” are created in pre-post as well.
I use postman in order to do automatic hourly variable request.
I’m new to APIs and programming.
MJW
November 27, 2020, 10:53pm
4
Please check the pre-request script, timestamp and signature are both processed specially;
You need to add something like below:
parameters.map((param) => {
if (
param.key != ‘quantity’ &&
param.key != ‘signature’ &&
param.key != ‘timestamp’ &&
!is_empty(param.value) &&
!is_disabled(param.disabled)) {
paramsObject[param.key] = param.value;
}
})
Object.assign(paramsObject, {‘quantity’: <your quantity var>}); // Need to make sure the order in the url and here in the object are consistent
Object.assign(paramsObject, {‘timestamp’: ts});
Good friend,
I have tried to do the same as your request but it does not work for me.
My intention in trying to change the quantity in the pre-request script
The quantity is updated in the url of post but I have the same error.
How could I fix it?
Thanks
MJW
March 20, 2021, 2:41am
7