Share URLs created via API do not work, if redirected or linked to


Hi there,

we are trying to list some files from a NextCloud inside a WordPress site, so that users can click to download the files from there.

First, we made a WEBDAV propfind request to get the list of files. That part is working fine.

Then, we are creating links to a WP Rest API endpoint, that we are passing the fileId to. We don’t know the maximum number of files the customer will eventually upload into the folder, so we did not want to make API requests to request the share URLs for all of those files pre-emptively, but we only do it when the user requests a specific file, by clicking on the link we present them.

We used the /ocs/v2.php/apps/dav/api/v1/direct endpoint, and had previously tested this using Postman. We got the share URL copy&pasted that into the browser - it worked fine, we got the specific file download.

Now when we are making that same request from within our WordPress, we also get a share URL back from the endpoint - but those are only working “partially”.

When I redirect to that URL, or output it as href of a link for the user to click on, the result in both cases is the same: We get a “503 Service Unavailable” response from the cloud.
Reloading via [f5] - still 503.

But then, when I click into the browser address bar, that is currently showing a URL of the form{token}, and submit via [enter] - then the download works, every single time.

It does not appear to be a timing issue - I can press [f5] to reload after waiting a full minute or more, the response is still 503. But as soon as we explicitly submit the request for the same URL via the address bar, it works - no matter whether that happens “immediately” after we got the first 503, or wait for longer.

Does anybody have an idea, what could be causing this behavior?

We are using Nextcloud 19.0.4.
I can see the 503 for the GET request in the web server’s log file, but not further error information besides that.

Thanks in advance,
Christoph / jagdfieber

Are any other routes accessible from your application? Are you accessing Nextcloud through a wrong hostname? Analyze the response body to possibly find out more and study the nextcloud logs.

Hi @jagdfieber, did you manage to find any solution? I have the same situation here.

If you only use a small number of files you can use the app Sharing Path (video).