Notify Public Link Via Email
Introduction
The public-files API allows access to public links via WebDAV.
Request Path | Method | Content Type |
---|---|---|
|
|
|
Request Parameters
Attribute | Type | Description |
---|---|---|
|
string |
The format to return the response body in.
The allowed options are |
POST Parameters
Attribute | Type | Description |
---|---|---|
|
array of string |
A list of email addresses to send the notification to. |
|
string |
The public link. |
|
string |
A personal note to send with the email notification. |
Code Example
#!/usr/bin/env bash
USERNAME=username
PASSWORD=password
API_PATH="ocs/v1.php/apps/files_sharing/api/v1/notification/notify-public-link-by-email"
SERVER_URI="https://owncloud.install.com/owncloud"
curl "$SERVER_URI/$API_PATH/" \
-X POST \
--data "recipients[]=user@example.com" \
--data "link=$SERVER_URI/index.php/s/sfU97LuwePm5omD" \
--data "personalNote=A personal note." \
--user "$USERNAME:$PASSWORD"
<?php
declare(strict_types=1);
use GuzzleHttp\Client;
require_once ('vendor/autoload.php');
// Configure the basic client
$basePath = 'https://owncloud.install.com/owncloud';
$requestPath = 'ocs/v1.php/apps/files_sharing/api/v1/notification/notify-public-link-by-email';
$username = 'username';
$password = 'password';
$client = new Client([
'base_uri' => $basePath,
]);
try {
$response = $client->post($requestPath, [
'auth' => [$username, $password],
'form_params' => [
'recipients' => [
'user@example.com',
],
'link' => 'https://owncloud.install.com/owncloud/index.php/s/sfU97LuwePm5omD',
'personalNote' => 'A personal note.',
]
]);
print $response->getBody()->getContents();
} catch (\GuzzleHttp\Exception\ClientException $e) {
print $e->getMessage();
}
Returns
Example Response
If the notification is successful, you will see the response below, along with an HTTP 200 status code — if you specified the format as `json`.
{
"ocs" : {
"meta" : {
"itemsperpage" : "",
"totalitems" : "",
"status" : "ok",
"statuscode" : 100,
"message" : "OK"
},
"data" : []
}
}
If the notification could not be sent to one or more recipients, you will see the response below, along with an HTTP 200 status code — if you specified the format as `json`.
{
"ocs" : {
"data" : [],
"meta" : {
"totalitems" : "",
"statuscode" : 400,
"itemsperpage" : "",
"message" : "Couldn't send mail to following recipient(s): test@email.com",
"status" : "error"
}
}
}
If public link mail notification is not allowed, then the following response will be returned, along with an HTTP 200 status code.
<?xml version="1.0"?>
<ocs>
<meta>
<status>failure</status>
<statuscode>403</statuscode>
<message>Public link mail notification is not allowed</message>
<totalitems></totalitems>
<itemsperpage></itemsperpage>
</meta>
<data/>
</ocs>