Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

WebDav method OPTIONS fail with "400 Bad Request" #12656

Closed
Geraldf opened this issue Nov 25, 2018 · 2 comments
Closed

WebDav method OPTIONS fail with "400 Bad Request" #12656

Geraldf opened this issue Nov 25, 2018 · 2 comments
Labels
bug design Design, UI, UX, etc.

Comments

@Geraldf
Copy link

Geraldf commented Nov 25, 2018

I try to use the webdav npm package https://www.npmjs.com/package/webdav to access next cloud via webdav. This package claims to work with nextcloud.

When I call the nextcloud wendav interface the package make an HTTP OPTIONS method, on which nextcloud replies with 400 Bad Request.

here is some Wireshark trace showing the request and the response.
bildschirmfoto 2018-11-25 um 19 15 38

bildschirmfoto 2018-11-25 um 19 15 38

the code which is doing the request is:
` const client = createClient(
process.env.WEBDAV_URL,
{
username: process.env.NEXTCLOUD_USER,
password: process.env.NEXTCLOUD_PASSWORD,
},
// Get directory contents

  // Outputs a structure like:
  // [{
  //     filename: "/my-file.txt",
  //     basename: "my-file.txt",
  //     lastmod: "Mon, 10 Oct 2018 23:24:11 GMT",
  //     size: 371,
  //     type: "file"
  // }]
);
client.getDirectoryContents('/').then(function(contents) {
  console.log(JSON.stringify(contents, undefined, 4));
});`

I am using nextcloud 14.0,.3

@nextcloud-bot nextcloud-bot added the design Design, UI, UX, etc. label Nov 25, 2018
@nextcloud-bot
Copy link
Member

GitMate.io thinks possibly related issues are #3738 (Webdav), #4199 (Error 400 - WebSockets for Bad Request), #10505 (Bulk import of about 400 randomly fails), #1814 (DEVONthink + WebDAV not working (400)), and #6026 (User Provisioning API request fails with "Bad request").

@Geraldf
Copy link
Author

Geraldf commented Nov 26, 2018

I solved my reported issue.
the reason for the "400 bad request" was that I was calling the URL, which was not part of the trusted_domains entries in the config/config.php file.
after adding the domain there, the 400-error disappeared.

the remaing CORS error I did get, I could solve by adding the following to the Apache conf file,

Header set Access-Control-Allow-Origin '*'
Header set Access-Control-Allow-Methods 'OPTIONS, GET, HEAD, DELETE, PROPFIND, PUT, PROPPATCH, COPY, MOVE, REPORT'
Header set Access-Control-Allow-Headers 'Authorization, Depth'

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug design Design, UI, UX, etc.
Projects
None yet
Development

No branches or pull requests

2 participants