400 Error For Every Request


Recommended Posts

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.




./btsync --config <config_path>curl -I -I
Mac OS X
/Applications/BitTorrent\ Sync.app/Contents/MacOS/BitTorrent\ Sync --config <config_path>curl -I -I
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": "",
    "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 host

Thanks for your help!



Link to comment
Share on other sites



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.

Link to comment
Share on other sites

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-cache

Although 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,



Link to comment
Share on other sites

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.

Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.