none
WebRequest 405 RRS feed

  • Question

  • Hi, i use a webdav console application and i have an error in GetResponseAsync function.

    Error: The remote server returned an error: (405) Method Not Allowed

    public async Task GetFolder(string url)
            {
                var request = GetWebRequest(url, "PROPFIND");
    
                string query = @"<?xml version=""1.0"" encoding=""utf-8""?>   <propfind xmlns=""DAV:"">     <propname/>   </propfind>";
                var bytes = Encoding.UTF8.GetBytes((string)query);
                request.ContentLength = bytes.Length;
                request.ContentType = @"application/xml; charset=""utf-8""";
    
                request.Headers.Add("Depth", "1");
    
                var requestStream = request.GetRequestStream();
                requestStream.Write(bytes, 0, bytes.Length);
                requestStream.Close();
    
                var response = await request.GetResponseAsync();
                var responseStream = response.GetResponseStream();
    
                var reader = new XmlTextReader(responseStream);
    
                string output = "";
    
                while (reader.Read())
                {
                    if (reader.Value.Contains("http"))
                    {
                        output += reader.Value.ToString() + "\n";
                    }
                }
    
                Console.WriteLine(output);
    
                reader.Close();
                responseStream.Close();
                response.Close();
            }

    Tuesday, January 22, 2019 12:50 PM

All replies

  • Karim samir,

    Sorry but you have posted to a forum that deals exclusively with questions/issues about customizing and programming Microsoft Project, a project management application. I suggest you re-post to the following forum:

    https://social.technet.microsoft.com/Forums/en-US/home?forum=whatforum

    John

    Tuesday, January 22, 2019 5:19 PM