0

I have the following POST request:

POST http://blah/Request HTTP/1.1
Host: blah
Content-Length: 322
Proxy-Connection: Keep-Alive

<?xml version="1.0"?>
<Envelope>
<Header>
<UserID>uid</UserID>
<Password>pass</Password>
<SessionID />
<RequestType>GetDetails</RequestType>
<POSCompany>01</POSCompany>
<PackageType>DATA</PackageType>
<ActionType>READ</ActionType>
<SnoopUserID />
</Header>
<Body>
<MagicNumber>124</MagicNumber>
</Body>
</Envelope>

This is failing with the error - (405) Method not supported

An example XML which apparently works on the server is the same but the header has the line POST /Request HTTP/1.1 instead of POST http://blah/Request HTTP/1.1.

I don't know if this is the problem but I am trying to eliminate all possibilites. However, I cannot get the POST request URI to be relative and not absolute. Is there a wat to do this?

The following is the code used for sending the XML.

Public Sub SendXML(ByVal file As String)
    Dim reader As New StreamReader(file)
    Dim data As String = reader.ReadToEnd()
    reader.Close()
    Dim request As HttpWebRequest = WebRequest.Create("http://blah/Request")
    request.Method = "POST"

    System.Net.ServicePointManager.Expect100Continue = False

    Dim bytes As Byte() = System.Text.Encoding.ASCII.GetBytes(data)
    request.ContentLength = bytes.Length

    Dim oStreamOut As Stream = request.GetRequestStream()
    oStreamOut.Write(bytes, 0, bytes.Length)
    oStreamOut.Close()

    Dim response As HttpWebResponse = request.GetResponse()

End Sub

Asked here in response to a request at 405 - Method Not Allowed HttpWebRequest

Community
  • 1
  • 1
anothershrubery
  • 20,461
  • 14
  • 53
  • 98

1 Answers1

0

Following HTTP Error 405 Method not allowed

405 errors often arise with the POST method. You may be trying to introduce some kind of input form on the Web site, but not all ISPs allow the POST method necessary to process the form.

All 405 errors can be traced to configuration of the Web server and security governing access to the content of the Web site, so should easily be explained by your ISP.

volody
  • 6,946
  • 3
  • 42
  • 54
  • As I say above, I have been provided with a file that does work and _apparently_ the third party server does accept POST requests. – anothershrubery Apr 05 '12 at 14:33
  • 1
    Marked as answer as we had been given the wrong IP for the server, it was one that was setup to accept `POST` requests from our parent company rather than ourselves. Numerous times they confirmed we were using the correct IP until eventually they realised it was wrong. – anothershrubery Apr 17 '12 at 08:36