? File path during API create share said 404 - how to get the right path

Dear ones, first of all thank you for letting me get help here.

I’m trying to create a new share with the API. The file i want to share is in the root of the owncloud with the name “feuervogel.jpg” - its a picture.

This is my source code:

$ user = “Dimensionssprung”;
$ pwd= “notincluded”;
$ base_uri = “https://www.vernetzt-systeme.de/sci-owncloud”;
$ API_PATH = “/ ocs / v1.php / apps / files_sharing / api / v1 / shares”;
$ expiredate = “2021-10-31”;
// Store the data to be transferred
$ data = [
‘path’ => ‘/feuervogel.jpg’,
‘shareType’ => ‘3’,
‘permissions’ => ‘1’,
‘expireDate’ => $ expiredate,
‘name’ => ‘fabijennas_test’
];

// We open the connection
$ ch = curl_init ();
// We are preparing the login
curl_setopt ($ ch, CURLOPT_URL, $ base_uri. $ API_PATH);
curl_setopt ($ ch, CURLOPT_USERPWD, “$ user: $ pwd”);
// We create a new share
curl_setopt ($ ch, CURLOPT_POST, $ data);
$ response = curl_exec ($ ch);
var_dump ($ response);
// We end the connection
curl_close ($ ch);

The file “feuervogel.jpg” that I want to share is in the path (seen with ftp)

/ html / sci-owncloud / data / Dimensionssprung / files

of the server and has a 0644 as file right.

What has to be in the variable “path” as path and file name?

I tried it

“/files/feuervogel.jpg”

or

“/feuervogel.jpg”

or

“Dimensionssprung / files / feuervogel.jpg”

or

“feuervogel.jpg”

but the system always gives a “failure 404 Please specify a file or folder path bool (true)

back as a mistake! So i think, the path is wrong !

Thanks for a tip!

Rainer Strebel

You could put everything into one string to post:

$ch = curl_init ();
curl_setopt ($ch, CURLOPT_URL, "$base_uri$API_PATH?name=fabijennas_test&path=/feuervogel.jpg&shareType=3&permissions=1&expireDate=$expiredate");
curl_setopt ($ch, CURLOPT_USERPWD, "$user:$pwd");
curl_setopt ($ch, CURLOPT_CUSTOMREQUEST, 'POST');
$response = curl_exec ($ch);
var_dump ($response);
curl_close ($ch);

Usually, this works.

The mistake was a misformed data - this works:

$data = array(
‘path’ => ‘/feuervogel.jpg’,
‘shareType’ => ‘3’,
‘permissions’ => ‘1’,
‘expireDate’ => $expiredate,
‘name’ => ‘fabijennas_test’
);

Thx
rainer strebel