Create email-share using external script using API or SQL?

Hi there,

can i share a file to an email recipent using the API?
Or by an SQL INSERT?

and what if i don’t know the fileif but the path?

Greetings

You should use the API and yes it is possible. I think you need to know the file or the folder that you want to share.

hi and thx for replying!

although IMHO i did everything as described in the docs (https://docs.nextcloud.com/server/16/developer_manual/client_apis/OCS/ocs-share-api.html#get-all-shares), i still get error messages when using the API.
The only thing that actually works is getting the own userinfo.

i feel like either i am really stupid or the manual is pretty incomplete
also there doesn’t seem to be even one complete example in the docs :frowning:

working:

API_PATH="/ocs/v1.php/cloud/users/downloads"
echo \
curl "$SERVER_URI/$API_PATH/" -X GET -H "OCS-APIRequest: true" --user "${USERNAME}:${PASSWORD}"
curl "$SERVER_URI/$API_PATH/" -X GET -H "OCS-APIRequest: true" --user "${USERNAME}:${PASSWORD}"

not working:

API_PATH=“ocs/providers.php”
echo
curl “$SERVER_URI/$API_PATH/” -X GET -H “OCS-APIRequest: true” --user “${USERNAME}:${PASSWORD}”
curl “$SERVER_URI/$API_PATH/” -X GET -H “OCS-APIRequest: true” --user “${USERNAME}:${PASSWORD}”

not working:

API_PATH=“ocs/v2.php/apps/dav/api/v1/direct”
echo
curl “$SERVER_URI/$API_PATH/” -X POST -H “OCS-APIRequest: true” --user “${USERNAME}:${PASSWORD}” --data “fileid=$shareid”
curl “$SERVER_URI/$API_PATH/” -X POST -H “OCS-APIRequest: true” --user “${USERNAME}:${PASSWORD}” --data “fileid=$shareid”

not working:

API_PATH=“ocs/v2.php/apps/files_sharing/api/v1/shares”
echo
curl “$SERVER_URI/$API_PATH/” -X GET -H “OCS-APIRequest: true” --user “${USERNAME}:${PASSWORD}”
curl “$SERVER_URI/$API_PATH/” -X GET -H “OCS-APIRequest: true” --user “${USERNAME}:${PASSWORD}”

wich would result in:

curl https://cloud.mycloud.tld/ocs/v2.php/apps/files_sharing/api/v1/shares/ -X GET -H OCS-APIRequest: true --user downloads:mypass

<?xml version="1.0"?> failure 404 Invalid query, please check the syntax. API specifications are here: http://www.freedesktop.org/wiki/Specifications/open-collaboration-services.

any idea?
currently i insert the SQL tables into the DB manually but that is not really the clean way…

funfact:
http://www.freedesktop.org/wiki/Specifications/open-collaboration-services.
is a dead link…