Rclone rc HTTP call with _config flag fails

Hi guys,

I'm using rclone via the remote control functionality. I send all my commands via a self-written application and HTTP/REST which works fine. I'm also using the sync/sync enpoint for starting file transfers and it works.
But: Sometimes, I want to adjust the configs (what is also called global flags), e.g. dryrun, transfers, etc.

I have read the rc documentation which says, that I have to pass the "_config" parameter with the command. Therefore, I've just added the _config parameter to the parameters and I'm trying to send the following:

{
    "srcFs": "C:/test",
    "dstFs": "onedrive:/test/",
    "createEmptySrcDirs": true,
    "_config": {
        "DryRun": true
    },
    "_async": true
}

This request fails and returns the following error:

{
        "error": "key \"_config\": invalid character 'D' looking for beginning of value",
        "input": {
                "_async": "True",
                "_config": "DryRun",
                "createEmptySrcDirs": "True",
                "dstFs": "onedrive:/test/",
                "srcFs": "C:/test"
        },
        "path": "sync/sync",
        "status": 400
}

If I remove the _config parameter, then the HTTP requests does not throw an error (Response Code 200).

I'm using rclone v1.56.0

Do you know what causes the error?
Thanks for your support!
Best regards,

Jojojoxx

Hi Jojojoxx,

I am new to the rclone rc functionality, but ready to give a helping hand if you can give me a simple example to start from.

I am looking for an example that will do:

rclone sync ./testfolder1 ./testfolder2 --dry-run

Using commands something like this:

$request='{…}'
rclone rc --loopback sync/sync --json $request

That will be a good starting point to find any JSON syntax errors - and can easily be expanded with curl usage if needed.

Hi Ole,

thanks for your answer.
the problem is, that my request works with rclone rc sync/sync --json command but doesn't when sending a HTTP/REST call with exactly the same string. If I remove _config parameter it also works via HTTP/REST.
Best regards,

Jojojoxx

OK, then let's try with curl.

Assume I have started rclone rcd with default parameters in another terminal.

What are the commands needed to perform my above example, I guess something like:

$request='{…}'
curl -H "Content-Type: application/json" -X POST -d $request http://localhost:5572/sync/sync

I played a bit around with curl and for some reason, I got it working now, I used the following command:

curl -i -H "Content-Type: application/json" -X POST -d "{\"srcFs\": \"R:/a\", \"dstFs\": \"R:/b\", \"_config\": { \"DryRun\": true }, \"_async\": true }" http://localhost:5572/sync/sync

Then, I started the implementation of the part of my application which raises the call from scratch and now it works. I don't know what I did wrong, but it's working now! Thanks for your support :slight_smile:
Best regards,

Jojojoxx

1 Like

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