Forums

Binance private method requests library - 400 error

Hi!

when trying to access some private info from binance website - get 400 response. Using request library, everything working fine on my pc and even on pythonAnywhere bash console, but when using scheduled tasks(always-on) (available on paid account) have issues with getting response from my Binance account through Binance API. Confused.

Are you loading authentication information from a file using a relative path? https://help.pythonanywhere.com/pages/NoSuchFileOrDirectory/

No, not loading anything. I have a .py file where I store my authentification info as a string. The same file contains main function, that runs the script.

Ok. Then perhaps look at the content of the response. Perhaps there is an error message in there that can act as a clue for debugging. In general, a 400 response means that the request was invalid - for example, making a GET request to an endpoint that does not accept GET requests.

Ok, the logs are following:

Max retries exceeded with url: /api/v3/allOrders - that's first launch. in another launch program scheduled execution I get something like {'code': -1021, 'msg': 'Timestamp for this request is outside of the recvWindow.'}. And in another trial it works fine.

The problem must be on pythonAnywhere side, because it works perfectly fine on my PC

Also, please, note that this problem does not occur if I run the same script through bash console here, on PythonAnywhere, it only happens if I run this script through 'always-on' tasks

It looks like something we need to dive deeper into. We will get to that on Monday.

It looks like it was related to intermittent network problems on the machine your code is running on. Let us know if you see that problem again.