How to upload and share file automatically

Nextcloud version 12
Operating system and version Centos 7.3
Apache 2.4.6
PHP version 70

I would like to know can Nextcloud upload and share file automatically?

I saw from the Doc that it can be done by calling Webdav API with curl. I’m not sure if there are any further configuration that I have to do or I can just call the API directly.

I tried to run this command:
curl -u admin:pass -T testfile.txt “

and then there is an error below:
<d:error xmlns:d=“DAV:” xmlns:s=“”>
<s:message>Permission denied to create file (filename testfile.txt)</s:message>

here is a nextcloud log:
{“reqId”:“WYk0H4IiMH8GiSK26jkHggAAAAI”,“level”:1,“time”:“2017-08-08T03:46:39+00:00”,“remoteAddr”:“”,“user”:"–",“app”:“admin_audit”,“method”:“PUT”,“url”:"/remote.php/dav/files/testfile.txt",“message”:“Login attempt: “admin””,“userAgent”:“curl/7.29.0”,“version”:“”}
{“reqId”:“WYk0H4IiMH8GiSK26jkHggAAAAI”,“level”:1,“time”:“2017-08-08T03:46:39+00:00”,“remoteAddr”:“”,“user”:“5AF09698-865E-420F-9E33-91215EAF4058”,“app”:“admin_audit”,“method”:“PUT”,“url”:"/remote.php/dav/files/testfile.txt",“message”:“Login successful: “5AF09698-865E-420F-9E33-91215EAF4058"”,“userAgent”:“curl/7.29.0”,“version”:“”}
{“reqId”:“WYk0H4IiMH8GiSK26jkHggAAAAI”,“level”:3,“time”:“2017-08-08T03:46:39+00:00”,“remoteAddr”:“”,“user”:“5AF09698-865E-420F-9E33-91215EAF4058”,“app”:“PHP”,“method”:“PUT”,“url”:”/remote.php/dav/files/testfile.txt",“message”:“call_user_func() expects parameter 1 to be a valid callback, class ‘OCA\QuotaWarning\AppInfo\Application’ does not have a method ‘login’ at /var/www/html/nextcloud/lib/private/legacy/hook.php#106”,“userAgent”:“curl/7.29.0”,“version”:“”}

Is my command correct ?
what is wrong for this case ?

The username in the url seems to be missing:

Hi tflidd

Thank you for you reply. I followed the Doc you provided. I just added the User ID to the URL and then it’s work but the Doc doesn’t show up how to share a file with curl.

Do you have any suggestion ?

There is also an API in the docs for that:

you can do it with curl as well. However, there is a python client that can do all of that and it’s even in the examples: