Excludes and filters do not work via API

What is the problem you are having with rclone?

Invoking exclude if present via API does not work. Same command via rc works. I tried with filters, excluding folders, etc.. and the result is the same. Via API it simply syncs the folder even if .ignore file is present in the folder.

Run the command 'rclone version' and share the full output of the command.

rclone v1.69.1

  • os/version: alpine 3.21.2 (64 bit)
  • os/kernel: 6.8.0-55-generic (x86_64)
  • os/type: linux
  • os/arch: amd64
  • go/version: go1.24.0
  • go/linking: static
  • go/tags: none

Which cloud storage system are you using? (eg Google Drive)

OneDrive

The command you were trying to run (eg rclone copy /tmp remote:tmp)

 curl -X POST 'http://XXXX:XXXX@192.168.1.101:5572/sync/sync?srcFs=/Docker/configs/p
hotoprism/storage&dstFs=onedrive:/Docker/configs/photoprism/storage&exclude-if-present=.ignore'```

rclone sync /Docker/configs/photoprism/storage onedrive:/Docker/configs/photoprism/storage --exclude-if-present=.ignore'

A log from the command with the -vv flag

both commands produce same input as below:

 "input": {
                "dstFs": "onedrive:/Docker/configs/photoprism/storage",
                "exclude-if-present": ".ignore",
                "srcFs": "/Docker/configs/photoprism/storage"
        },
        "path": "sync/sync",
        "status": 500

You need to use the correct names. See

$ rclone rc options/get --loopback | jq .filter
{
  "DeleteExcluded": false,
  "ExcludeFile": [],
  "ExcludeFrom": [],
  "ExcludeRule": [],
  "FilesFrom": [],
  "FilesFromRaw": [],
  "FilterFrom": [],
  "FilterRule": [],
  "IgnoreCase": false,
  "IncludeFrom": [],
  "IncludeRule": [],
  "MaxAge": 9223372036854776000,
  "MaxSize": -1,
  "MetaRules": {
    "ExcludeFrom": [],
    "ExcludeRule": [],
    "FilterFrom": [],
    "FilterRule": [],
    "IncludeFrom": [],
    "IncludeRule": []
  },
  "MinAge": 9223372036854776000,
  "MinSize": -1
}

Then you need to use _filter to set them. See Remote Control / API where it goes into examples of specifying this.

I map them as follows:

    param2flag = {
        "DeleteExcluded": "--delete-excluded",
        "FilterRule": "--filter",
        "FilterFrom": "--filter-from",
        "ExcludeRule": "--exclude",
        "ExcludeFrom": "--exclude-from",
        "IncludeRule": "--include",
        "IncludeFrom": "--include-from",
        "ExcludeFile": "--exclude-if-present",
        "FilesFrom": "--files-from",
        "FilesFromRaw": "--files-from-raw",
        "MinAge": "--min-age",
        "MaxAge": "--max-age",
        "MinSize": "--min-size",
        "MaxSize": "--max-size",
        "IgnoreCase": "--ignore-case",
        "meta_FilterRule": "--metadata-filter",
        "meta_FilterFrom": "--metadata-filter-from",
        "meta_ExcludeRule": "--metadata-exclude",
        "meta_ExcludeFrom": "--metadata-exclude-from",
        "meta_IncludeRule": "--metadata-include",
        "meta_IncludeFrom": "--metadata-include-from",
    }

where the meta_ get put into MetaRules