FetchData method

Set request to HTTP server and retrieves server response.

FetchData url[,method]

Parameters

url
The url string to send request to.
method
Optional. The string specifying the HTTP request method. The following strings are valid: "GET","POST","HEAD". The default method is "GET".

Return value

The method returns zero if success, error code overwise. The error codes are the same as for LastError low-level method
You should take into account that this is a TCP/IP low level error. It occures, for example, if server is down or network connection is broken. Even if the connection is reached successfully, the server could return the HTTP protocol error code, for example, 404 (file not found). This is the reason why it's a good idea to check the StatusCode property instead or in addition to.

Notes

The Url string for this method has the following format:
http://[login:password@]server[:port][/path]
The default port is 80, the default path is root (/). Here is the examples of valid urls:
http://myserver.domain.com/
http://myserver.domain.com:8000/
http://john:jonny@myserver.domain.com/path/to/file.htm


If you use the challenge/response NT authorization method, you should not use the '@' url specification.

The retrieved data can be accessed using the Convert method.

Example

The following example retrieves HTML text from the url:

Set tcpip=CreateObject("SHOTIP.Connection")
Set http=tcpip.http
url="http://thatserver.domain.com/the/required/document.htm"
http.FetchData url
if http.StatusCode = 200 then
 text = http.Convert(2)
end if