/rest/db/file API call

Dear syncthing community,

I’m trying to use the Synthing REST API for some own project but I don’t really understand the /rest/db/file API endpoint.

https://docs.syncthing.net/rest/db-file-get.html

“Takes folder and file parameters”

For the “file” parameter I tried everything from fullpath, file name to some ID I found in some logs. But sadly I don’t get any data back.

Can you provide an example for this API call?

Its file path to relative to the root of the folder.

Sorry but I don’t get it :frowning:

curl -k -H "X-API-Key: xxxxxxxxxxxxxxxxxxxxxxx" https://xxxxxxxxxx:xxxx/rest/db/browse?folder=wjnky-k2h7h | jq
{
  "17802.mxf": [
    "2016-06-13T00:32:52.2628428+02:00",
    909919948
  ],
  "17802_tmp.mxf": [
    "2016-06-13T16:20:27.6176736+02:00",
    905249982
  ],
  "20160901_401660_00.mxf": [
    "2016-07-08T22:06:31+02:00",
    577368220
  ],
  "20160901_401660_00_new.mxf": [
    "2016-09-07T15:18:53.0718864+02:00",
    575894669
  ],
  "401660_new.mxf": [
    "2016-09-09T15:20:11.2201511+02:00",
    575894669
  ],
  "PC130264_5F5E416137F94D52A0FA01BC13A99E65.mxf": [
    "2016-06-22T11:38:35.6351534+02:00",
    1780744331
  ],
  "PC137323_C569CC6D5AB14C0E81B9ECB9A718FEBB.mxf": [
    "2013-10-17T12:50:12+02:00",
    12108147884
  ],
  "PC137323_C569CC6D5AB14C0E81B9ECB9A718FEBB_new.mxf": [
    "2016-07-12T13:10:34.0696139+02:00",
    12074105407
  ],
  "RPA_548549312A214FA78AA05E920AE72F4A.mxf": [
    "2014-08-04T19:02:48+02:00",
    57058668008
  ],
  "RPA_DAA88991C19B4FB3B8D0775ADEBBF5AF.mxf": [
    "2013-10-22T10:07:12+02:00",
    26396621156
  ],
  "test": {
    "401660.mxf": [
      "2016-09-01T17:03:34.8771531+02:00",
      579496604
    ]
  }
}

curl -k -H "X-API-Key: xxxxxxxxxxxxxxxxxxxxxxx" https://xxxxxxxxxx:xxxx/rest/db/file?folder=wjnky-k2h7h&file=RPA_DAA88991C19B4FB3B8D0775ADEBBF5AF.mxf | jq
No such object in the index

Same with /RPA_DAA88991C19B4FB3B8D0775ADEBBF5AF.mxf and URL encoded %2FRPA_DAA88991C19B4FB3B8D0775ADEBBF5AF.mxf

What am I doing wrong?

Can you explain what are you trying to achieve ?

I’m trying to “return most data available about a given file, including version and availability.” as described here GET /rest/db/file — Syncthing v1 documentation

:slight_smile:

EDIT: In the example above “RPA_DAA88991C19B4FB3B8D0775ADEBBF5AF.mxf” is one file at the root of the folder “wjnky-k2h7h”

From what you posted it looks like it should work, so I’d have to try and repro myself. Poke around and if you can’t get it to work open an issue on github as a reminder for someone to look at.

Ok will do. Thanks! :wink:

Just to be sure - the ampersand & is a shell special character. If you don’t quote it as \& or put the whole URL in quotes, the curl command will probably not do what it looks like, and you’ll get an error similar to the one you quote.

1 Like

@calmh :joy: you’re right! Thanks it works :slight_smile:

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