Have any changes been made to the OCS APIs recently?
I have been using a PHP script on our Nextcloud server for a long time, which creates a few new folders via WebDAV and generates public shared links for these folders via OCS API.
Recently I noticed that this PHP script no longer works. At first I thought it was due to the change from PHP 8.2 to PHP 8.3, but after switching back - even to PHP 8.1 - the script still didn’t work.
It may be related to the upgrade of Nextcloud from V28.0.10 to V29.0.12 - I did this upgrade in the last few weeks.
Summary of the issue you are facing:
I have access to different Nextcloud servers. Therefore, I can present the queries from different NC versions:
- system1 : NC 30.0.4
- system2 : NC 29.0.12
- system3 : NC 13.0.4
Faulty OCS API reqeusts
When I try to query the list of shares via OCS API, I get no response (or an empty response) from the new servers.
Nextcloud 30.0.4 : failure, no response
sh$ curl --verbose --insecure --header 'OCS-APIRequest: true' --user 'user:password' --request GET https://server1.domain.tld/ocs/v2.php/apps/files_sharing/api/v1/shares
[...]
* SSL connection using TLSv1.3 / TLS_AES_256_GCM_SHA384 / X25519 / RSASSA-PSS
[...]
< set-cookie: oc9gl640os51=0ee8006579de3b89a4275636b9544714; path=/; secure; HttpOnly; SameSite=Lax
< strict-transport-security: max-age=31536000
<
* Connection #0 to host server1.domain.tld left intact
Nextcloud 29.0.12 : failure, no response
sh$ curl --verbose --insecure --header 'OCS-APIRequest: true' --user 'user:password' --request GET https://server2.domain.tld/ocs/v2.php/apps/files_sharing/api/v1/
[...]
* SSL connection using TLSv1.2 / ECDHE-RSA-AES128-GCM-SHA256 / X25519 / RSASSA-PSS
[...]
< set-cookie: oceqxk3dci5e=db72653d8612c9058eae0582584f087c; path=/; secure; HttpOnly; SameSite=Lax
<
* Connection #0 to host server2.domain.tld left intact
Nextcloud 13.0.4 : success, list of shares, XML formated
sh$ curl --verbose --insecure --header 'OCS-APIRequest: true' --user 'user:password' --request GET https://server3.domain.tld/cloud/ocs/v2.php/apps/files_sharing/api/v1/shares
[...]
* SSL connection using TLSv1.2 / ECDHE-RSA-AES256-GCM-SHA384 / prime256v1 / rsaEncryption
[...]
< Content-Length: 77189
< X-Content-Type-Options: nosniff
< X-XSS-Protection: 1; mode=block
< X-Robots-Tag: none
< X-Download-Options: noopen
< X-Permitted-Cross-Domain-Policies: none
< Content-Type: application/xml; charset=utf-8
<
<?xml version="1.0"?>
<ocs>
<meta>
<status>ok</status>
<statuscode>200</statuscode>
<message>OK</message>
</meta>
<data>
<element>
<id>1</id>
[...]
</element>
</data>
</ocs>
* Connection #0 to host server3.domain.tld left intact
Successful OCS API requests
Some other OCS APIs still works. For example, querying the server capabilities:
Nextcloud 30.0.4 : success
sh$ curl --verbose --insecure --header 'OCS-APIRequest: true' --user 'user:password' --request GET https://server1.domain.tld/ocs/v1.php/cloud/capabilities
[...]
< vary: Accept-Encoding
< strict-transport-security: max-age=31536000
<
<?xml version="1.0"?>
<ocs>
[...]
<data>
<version>
<major>30</major>
<minor>0</minor>
<micro>4</micro>
<string>30.0.4</string>
<edition></edition>
<extendedSupport></extendedSupport>
</version>
[...]
</data>
</ocs>
* Connection #0 to host server1.domain.tld left intact
Nextcloud 29.0.12 : success
sh$ curl --verbose --insecure --header 'OCS-APIRequest: true' --user 'user:password' --request GET https://server2.domain.tld/ocs/v1.php/cloud/capabilities
[...]
< set-cookie: oceqxk3dci5e=....; path=/; secure; HttpOnly; SameSite=Lax
< etag: "...."
<
<?xml version="1.0"?>
<ocs>
[...]
<data>
<version>
<major>29</major>
<minor>0</minor>
<micro>12</micro>
<string>29.0.12</string>
<edition></edition>
<extendedSupport></extendedSupport>
</version>
[...]
</data>
</ocs>
* Connection #0 to host server2.domain.tld left intact
Summary
Can anyone tell me what happened here?
Is there any solution for this problem?
By the way, I found some error messages in my Nextcloud logs - see below, Log entries.
Thanks
Friedbert
The Basics
- Nextcloud Server version:
- 30.0.4
- 29.0.12
- 13.0.12 - really old system for cross check
- Operating system and version:
- IONOS cloud server, Debian 6.1.128
- IONOS Webhosting, Linux 4.4.400
- IONOS virtual host, Linux 3.10.0
- Web server and version:
- Apache 2.4.62
- ???
- Apache 2.2.2
- PHP version (e.g, 8.3):
- PHP 8.2.27
- PHP 8.2.27
- PHP 8.2.27
Log entries
Nextcloud
Nextcloud 30.0.4 :
{"reqId":"GomQytPmjTbc47hBjnEg","level":3,"time":"2025-03-15T12:00:45+00:00","remoteAddr":"87.123.150.7","user":"--","app":"PHP","method":"GET","url":"/ocs/v2.php/apps/files_sharing/api/v1/shares","message":"TypeError: Cannot assign null to property OCA\\Files_Sharing\\Controller\\ShareAPIController::$currentUser of type string at /var/www/html/apps/files_sharing/lib/Controller/ShareAPIController.php#94","userAgent":"curl/8.5.0","version":"30.0.4.1","data":{"app":"PHP"},"id":"67d571eb21a1a"}
{"reqId":"3NilGGS7vYiu0irm8Ljj","level":3,"time":"2025-03-15T11:44:31+00:00","remoteAddr":"87.123.150.7","user":"--","app":"PHP","method":"GET","url":"/ocs/v2.php/apps/files_sharing/api/v1/shares","message":"TypeError: Cannot assign null to property OCA\\Files_Sharing\\Controller\\ShareAPIController::$currentUser of type string at /var/www/html/apps/files_sharing/lib/Controller/ShareAPIController.php#94","userAgent":"curl/8.5.0","version":"30.0.4.1","data":{"app":"PHP"},"id":"67d571eb21aee"}
Nextcloud 29.0.12 :
{"reqId":"Z9VtGWYYYSztrUFU9WGivwAAAAY","level":3,"time":"2025-03-15T12:05:45+00:00","remoteAddr":"2001:9e8:2dcf:5400:1599:2398:1920:1234","user":"--","app":"PHP","method":"GET","url":"/ocs/v2.php/apps/files_sharing/api/v1/shares","message":"TypeError: Cannot assign null to property OCA\\Files_Sharing\\Controller\\ShareAPIController::$currentUser of type string at /homepages/0/xxx/htdocs/cloud/apps/files_sharing/lib/Controller/ShareAPIController.php#124","userAgent":"curl/8.5.0","version":"29.0.12.2","data":{"app":"PHP"},"id":"67d573c611fda"}
{"reqId":"Z9Vb4jQ2Q9IFzTwy1T4z2gAAAAk","level":3,"time":"2025-03-15T10:52:18+00:00","remoteAddr":"2001:9e8:2dcf:5400:1599:2398:1920:1234","user":"--","app":"PHP","method":"GET","url":"/ocs/v2.php/apps/files_sharing/api/v1/shares","message":"TypeError: Cannot assign null to property OCA\\Files_Sharing\\Controller\\ShareAPIController::$currentUser of type string at /homepages/0/xxx/htdocs/cloud/apps/files_sharing/lib/Controller/ShareAPIController.php#124","userAgent":"curl/8.5.0","version":"29.0.12.2","data":{"app":"PHP"},"id":"67d573d045035"}