Some OCS APIs no longer respond

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:

  1. system1 : NC 30.0.4
  2. system2 : NC 29.0.12
  3. 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:
    1. 30.0.4
    2. 29.0.12
    3. 13.0.12 - really old system for cross check
  • Operating system and version:
    1. IONOS cloud server, Debian 6.1.128
    2. IONOS Webhosting, Linux 4.4.400
    3. IONOS virtual host, Linux 3.10.0
  • Web server and version:
    1. Apache 2.4.62
    2. ???
    3. Apache 2.2.2
  • PHP version (e.g, 8.3):
    1. PHP 8.2.27
    2. PHP 8.2.27
    3. 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"}

I tried it on latest master and for me it works fine:

✗ curl --insecure --header 'OCS-APIRequest: true' --user 'admin:admin' --request GET  https://nextcloud-mm.local/ocs/v2.php/apps/files_sharing/api/v1/shares 
 
<?xml version="1.0"?>
<ocs>
 <meta>
  <status>ok</status>
  <statuscode>200</statuscode>
  <message>OK</message>
 </meta>
 <data>
  <element>
   <id>46</id>
   <share_type>1</share_type>
   <uid_owner>admin</uid_owner>
   <displayname_owner>admin ABC</displayname_owner>
   <permissions>31</permissions>
   <can_edit>1</can_edit>
   <can_delete>1</can_delete>
   <stime>1741727154</stime>
   <parent/>
   <expiration/>
   <token/>
   <uid_file_owner>admin</uid_file_owner>
   <note></note>
   <label></label>
   <displayname_file_owner>admin ABC</displayname_file_owner>
   <path>/Media</path>
   <item_type>folder</item_type>
   <item_permissions>31</item_permissions>
...

The exceptions you postet match the time for the curl calls?

You might want to try to update to 30.0.7 to check if the exception was already fixed.

Hello Marcel,

thanks for the quick response!

I tried NC 30.0.7 on my server1 - that´s my test system, where I try new software versions. My server2 is the productive system, where I like to have an older, stable software version.

Nextcloud 30.0.7 : first the server capabilities - success:

sh$ curl --verbose --insecure --header 'OCS-APIRequest: true' --user 'user:password' --request GET  https://server1.domain.tld/ocs/v1.php/cloud/capabilities
[...]
< strict-transport-security: max-age=31536000
<
<?xml version="1.0"?>
<ocs>
 [...]
 <data>
  <version>
   <major>30</major>
   <minor>0</minor>
   <micro>7</micro>
   <string>30.0.7</string>
   <edition></edition>
   <extendedSupport></extendedSupport>
  </version>
 [...]
 </data>
</ocs>
* Connection #0 to host server1.domain.tld left intact

… and second, the list of public shares - failure

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
[...]
< strict-transport-security: max-age=31536000
<
* Connection #0 to host server1.domain.tld left intact

And, yes, the logged error message matches this request:

{"reqId":"S4GbYlvP8oO7igacCjRq","level":3,"time":"2025-03-15T14:32:28+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.7.2","data":{"app":"PHP"},"id":"67d58fd9081a1"}

Regards,
Friedbert