'WebDAV return 401 - How to authenticate?
I have a problem with WebDAV. I have to get a list of files. I have this request:
<?xml version="1.0"?>
<D:searchrequest xmlns:D = "DAV:">
<D:sql>
SELECT "DAV:displayname" FROM "address" WHERE "DAV:ishidden" = false AND "DAV:isfolder" = false
</D:sql>
</D:searchrequest>
Response:
401 - Unauthorized: Access is denied due to invalid credentials.
I have user and password (who has access), but I don't know, how I can put this data to XML request.
Solution 1:[1]
WebDAV uses an HTTP authentication.
So you put your credentials to an HTTP header, not to the WebDAV XML in the HTTP body.
The basic HTTP authentication works like:
You get a
WWW-Authenticate
header from the serverWWW-Authenticate: Basic realm="server"
You include the
Authorization
header to the next request. The value of the header is:Authorization: Basic username:password
where the
username:password
is in Base-64 encoding.Authorization: Basic dXNlcjpwYXNzd29yZA==
For details, see
- Basic access authentication on Wikipedia
- RFC 7235: Hypertext Transfer Protocol (HTTP/1.1): Authentication
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
Solution | Source |
---|---|
Solution 1 |