arthurlewis Posted July 8, 2014 Report Share Posted July 8, 2014 Hi there, I'm trying to make simple API requests to a locally-installed btsync client, but I'm getting a 400 request on each one. This happens both on CentOS and Mac OS X 10.8. Here's what I'm doing. CentOS----------./btsync --config <config_path>curl -I http://127.0.0.1:8888curl -I http://127.0.0.1:8888/api?method=get_os Mac OS X----------/Applications/BitTorrent\ Sync.app/Contents/MacOS/BitTorrent\ Sync --config <config_path>curl -I http://127.0.0.1:8888curl -I http://127.0.0.1:8888/api?method=get_os In all cases, I get the response:HTTP/1.1 400 ERRORConnection: keep-aliveContent-Length: 17Content-Type: text/html I've dwindled my config file down to the basics at this point: { "storage_path": "<storage_path>", "webui" : { "listen": "127.0.0.1:8888", "api_key": "<api_key>" }} I've verified that both of the storage_paths and config_paths do in fact exist, and the API Key is directly copied and pasted from the email. I must be missing something simple here, but I have no idea what it is. Is BTsync logging these errors somewhere? I'm not seeing anything new in /var/log on either machine, or in ~/Library/Logs or /Library/Logs on the Mac. There appears to be a sync.log under storage_path, but it doesn't seem to be logging anything from these requests. I know at least that BTSync is serving these 400 Errors, because as soon as I kill the process, I get the expected curl: (7) couldn't connect to hostThanks for your help! Arthur Quote Link to comment Share on other sites More sharing options...
RomanZ Posted July 9, 2014 Report Share Posted July 9, 2014 @arthurlewis That's strange. Actually, the data you supplied in your config should be enough to run BTSync in API mode (i tried it in my lab). The sync.log file should appear in storage folder. If it does not - try adding "--nodaemon" key so you'll see debug output directly into the terminal window. Quote Link to comment Share on other sites More sharing options...
arthurlewis Posted July 9, 2014 Author Report Share Posted July 9, 2014 Thanks @romanZ. I did some testing with --nodaemon and managed to figure out the problem. When I switched my curl flag to -i (instead of -I), I was able to see that the full response I was getting was:HTTP/1.1 401 UnauthorizedConnection: closeContent-Length: 0Content-Type: text/htmlWWW-Authenticate: Basic realm="BitTorrent Sync"Cache-Control: no-cacheAlthough the minimal config file I was testing with didn't ask for authentication, my original file did, so I guessed that that need for auth was being cached somewhere in my storage_path. I went into that folder and deleted everything (settings.dat, sync.dat, etc.), and I was able to get the expected response from the API. Is there a way to wipe or change the HTTP authentication requirement from the storage_path without having to delete the files in it? I was able to do it this time because we haven't actually started syncing anything yet, but I imagine it'll be more difficult in the future. Thanks again, Arthur Quote Link to comment Share on other sites More sharing options...
RomanZ Posted July 10, 2014 Report Share Posted July 10, 2014 @arthurlewis Try setting empty login and password. Quote Link to comment Share on other sites More sharing options...
nibzo1 Posted July 14, 2014 Report Share Posted July 14, 2014 Had the same issues, I ended up querying the api as so, hope it helps$http.get("http://username:password@192.168.0.1:8888/api?method=get_folders"+apiParams).success(function(data){$scope.data = data;}); Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.