I am trying to make my ruby application upload a zip file to a file drop folder in my nextcloud, but I only get 405 answers from nextcloud. Unfortunately, I was unable to find any documentation on how to do this or how such a post request is supposed to look like.
Can someone please hint me to what exact url and headers to use?
The only thing I found on that topic is this little curl script, but it did not help making it work (and it looks a bit outdated).
There is a client library in python, https://github.com/owncloud/pyocclient, perhaps this helps you to get some inspiration. I have only tried with a client login, never as a file drop.
Thank you a lot for pointing me to the right direction. It seems like I should be using a PUT request instead of a POST request.
Now I can get some results when testing with curl, though the upload is not successful yet.
The API documentation states that all requests need to provide authentication information, either as a Basic Auth header or by passing a set of valid session cookies. But this somehow defeats the purpose of having a public upload (file drop) page which does not need an account.
If I give curl test:test for user:password, just so to make it send an auth header, I get the error “No public access to this resource., Username or password was incorrect”.
Ok so after a long time of searching and trying I figured out a way to do this. Here is my solution in case somebody happens to be trying the same thing:
In Ruby we can upload easily using the PUT (not POST) with the mechanize gem:
I don’t know enough JS to help review any code, but looking at the screenshot, I can see that the error code is 409, which means it is a client error.
As mentioned above, I can’t help you with nodejs as I’ve never used it.
Get some guidance from the official API documentation and test your queries with curl.
I don’t know how you are expecting to use a file upload link. The api docs state (as also mentioned a few posts above) that you have to use the PUT http method to upload a file, so I’d rather try this or this.