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

Path params and hitting URL length limit (Unexpected end of JSON input)

Open TylerSanford opened this issue 2 years ago • 0 comments

Good Evening,

I have been seeing errors in my logs for the last week or so that cropped up from no code change. I use kucoin as my exchange and I update the bot settings when new pairs are added. Over the last few weeks I have seen the coins go from 790 to over 830 and sometime from 820ish I started seeing the exception FetchError: invalid json response body at https://api.3commas.io/public/api/ver1/bots/** reason: Unexpected end of JSON input

I was still able to use the same endpoint with a smaller list, but I am unable to update the list with all current kucoin USDT pairs.

I propose for POST/PUT calls we use the body instead of a query string within async makeRequest(method, path, params) { on line 24 in threeCommasAPI class.

From 3Commas documentation:

  • For GET endpoints, parameters must be sent as a query string.
  • For POST, PUT, and DELETE endpoints, the parameters may be sent as a query string or in the request body with content type application/x-www-form-urlencoded or application/json. You may mix parameters between both the query string and request body if you wish to do so.
  • Parameters may be sent in any order.
  • If a parameter sent in both the query string and request body, the query string parameter will be used.

TylerSanford avatar Apr 26 '23 04:04 TylerSanford