Discovery REST API

We are trying to use Syncthing API to automate discovery and acceptance of remote machines. Problem is that we aren’t finding success with the /rest/system/discovery POST command. Here is what we are attempting, with our IP/KEY/DEVICE obscured:

curl --verbose -X POST -H “X-API-Key:$API_KEY” ‘http://127.0.0.1:8384/rest/system/discovery?device=$REMOTE_DEVICE&addr=$REMOTE_IP:22000

curl --verbose -X POST -H “X-API-Key:$API_KEY” ‘http://127.0.0.1:8384/rest/system/discovery?device=$REMOTE_DEVICE&addr=dynamic

curl --verbose -X POST -H “X-API-Key:$API_KEY” 'http://127.0.0.1:8384/rest/system/discovery?device=$REMOTE_DEVICE&addr=tcp://$REMOTE_IP:22000

These all return the same result:

< HTTP/1.1 404 Not Found
< Cache-Control: max-age=0, no-cache, no-store
< Content-Type: text/plain; charset=utf-8
< Expires: Mon, 16 Nov 2015 18:00:07 GMT
< Pragma: no-cache
< X-Syncthing-Id: XXXXXXX-XXXXXXX-XXXXXXX-XXXXXXX-XXXXXXX-XXXXXXX-XXXXXXX-XXXXXXX
< X-Syncthing-Version: v0.12.2
< Date: Mon, 16 Nov 2015 18:00:07 GMT
< Content-Length: 19
< 
404 page not found

Neither the local machine nor the remote machine are showing log entries for these requests. Running GET requests is returning valid data, so the API is functioning. We were also able to perform these desired functions through the GUI without issue. Additionally, we removed the device from the local machine and tried adding it via a /rest/system/config POST request, which worked. We would like to get the /rest/system/discovery command working, as it is a simpler process. What are we doing wrong with discovery API?

You’re not doing anything wrong. What’s wrong is that the POST request to that URL is no longer supported in v0.12.x (it exists up to an including v0.11.26). It was removed because it didn’t fit cleanly in the rearchitected discovery subsystem in v0.12.0 and there were no known users of it. I’ve forgotten to mark the documentation for it as such - sorry about that, will fix.

However, depending on your setup, you may not need it. The config POST you found is the correct way to set a device address permanently. The discovery POST you attempted to use would have let Syncthing find the other device if the config said dynamic and you did the POST in question after each startup. If you have static IP:s, use the config post. If you need it dynamic (i.e. cannot put the IP into the config), please raise a feature request to resurrect the discovery POST method.

This topic was automatically closed 30 days after the last reply. New replies are no longer allowed.