'synology file station api upload file ,return 101

Full compliance with documentation(https://cndl.synology.cn/download/Document/Software/DeveloperGuide/Package/FileStation/All/enu/Synology_File_Station_API_Guide.pdf)。 I'm writing an Android program that includes a function of uploading files to filestation. It is written in full accordance with the document, but the server returns {"error": {"code": 101}, "success": false}. Refer to the document. Error 101 refers to "no parameter of API, method or version". But I use postman to test the same parameters and data, which can be uploaded successfully. I use rxhttp(https://github.com/liujingxing/rxhttp) to upload. The following is my upload code, please help me.

 RxHttp.patchForm("http://myIp:port/webapi/entry.cgi")
                    .add("api", "SYNO.FileStation.Upload")
                    .add("method", "upload")
                    .add("version", 3)
                    .add("path", "/newFolder")
                    .add("create_parents", false)
                    .add("size", "file size")
                    .addPart(context, "file", "file path")
                    .upload(AndroidSchedulers.mainThread(), progress -> {
                        int currentProgress = progress.getProgress();
                        //The progress is displayed normally from 0-100, and then the server 
                        //returns error 101
                        ALog.i(currentProgress);
                    })
                    .asString()
                    .subscribe(s -> {
                        ALog.i(s);  //{"error":{"code":101},"success":false}
                    }, throwable -> {
                        ALog.i(throwable.getMessage());
                    });

I did a packet capture test on the official file station app and found that the parameters of the uploaded file did not contain "content-length",This is the upload file of file station app

--5ed341e2-7d01-419a-bd7d-ecfd7cb1f1b3
Content-Disposition: form-data; name="api"

SYNO.FileStation.Upload

...

The following is the content captured after my code is run, and an additional "content-length" is compared

--5ed341e2-7d01-419a-bd7d-ecfd7cb1f1b3
Content-Disposition: form-data; name="api"
Content-Length: 23

SYNO.FileStation.Upload
...

But I don't think this will affect the upload, and I haven't found a way to remove the "content-length" in the parameter. So far, I guess it may be the "content-length" that causes the server to not recognize the parameter value. Please help me.



Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source