3commas-api-node icon indicating copy to clipboard operation
3commas-api-node copied to clipboard

Nested params not working with querystring.stringify

Open ran010 opened this issue 4 years ago • 7 comments

{ "account_id": 1, "pair": "USDT_BTC", "instant": "true", "position": { "type": "buy", "units": { "value": "0.01" }, "order_type": "market" } } querystring.stringify does not give correct params to send out in URL. I had to use qs to make it work.

ran010 avatar Dec 02 '21 09:12 ran010

Hey, same issue there, can you please post full code to make position works ? Would be very helpfull :)

mattguetta avatar Jan 24 '22 08:01 mattguetta

@mattguetta i had changed index.js
${this._url}${path}${querystring.stringify(params)} to ${this._url}${path}${qs.stringify(params)}

ran010 avatar Jan 24 '22 08:01 ran010

@ran010 Oh yeah got it thanks :) Have you been able to add take profit ? Got the same error with steps as it needs brackets

mattguetta avatar Jan 24 '22 09:01 mattguetta

there is pull request #26 which also replaces "querystring" library with "qs-stringify", would this resolve the issue? Can someone test this? If all good I can merge it

rentorm avatar Jan 24 '22 09:01 rentorm

Same issue here with take_profit true

error_attributes: { 'take_profit[steps]': [ 'is invalid' ], 'take_profit[steps][price][type]': [ 'is missing' ], 'take_profit[steps][price][value],take_profit[steps][price][percent]': [ 'are missing, exactly one parameter must be provided' ] }

Set it to false and you got it, probably because of nested [ ]

mattguetta avatar Jan 24 '22 09:01 mattguetta

I’ll give a try but any thoughts on how doing this are welcome ^^

https://github.com/3commas-io/3commas-official-api-docs/issues/31#issuecomment-1020202364

mattguetta avatar Jan 24 '22 15:01 mattguetta

Well, looks like this is the way to go but can't find how to, any help would be great :) https://github.com/3commas-io/3commas-official-api-docs/issues/19#issuecomment-739640270

mattguetta avatar Jan 24 '22 17:01 mattguetta