WinBatch Tech Support Home

Database Search

If you can't find the information using the categories below, post a question over in our WinBatch Tech Support Forum.

TechHome

WinInet
plus

Can't find the information you are looking for here? Then leave a message over on our WinBatch Tech Support Forum.

iHttpOpen Error 406


Question:

We need to retrieve a text file from an external Web server. While trying to diagnose the problems, we had our Network Administrator create a folder on our internal Web server containing a text file. Inside the text file is "This is a text file". We have a script that will download a gif from yahoo.com to a local file, but when we try to alter this script to download the above text file we get error 406. When we access the text file with IE, the contents are displayed. Our internal Web server is IIS.

The following is from checkupdown.com:

Resolving 406 errors - general
This error occurs very infrequently in Web browsers, because most browsers will accept any data returned from your Web server.
If the client is not a Web browser, then anyone can only investigate the problem by looking at the Accept headers generated by the client system and the data stream returned by the Web server. If you do not have access to the source code for these systems, the only thing you can do is refer the problem to technical support people at the companies that developed the systems.

Answer:

Maybe try using iHttpHeaders to obtain the response headers received from an iHttpOpen request.

You may have to send a HTTP_ACCEPT header set to *.*

;Define the headers
moreheaders="Accept Language: en-us"
moreheaders=StrCat(moreheaders,@CRLF,"Referer: http://techsupt.winbatch.com/techsupt/finickytest.html")
moreheaders=StrCat(moreheaders,@CRLF,"Accept: *.*")

rslt = iHttpOpen(datahandle, moreheaders, formdata, -1);

User Reply:

We finally stumbled onto the solution, partly due to the above suggestion.
moreheaders="Accept-Language: en-us"
moreheaders=StrCat(moreheaders,@CRLF,"Accept: image/*,text/*,audio/*,application/*")
rslt = iHttpOpen(datahandle, moreheaders, 0, 0);

Article ID:   W16893
File Created: 2017:08:29:11:33:15
Last Updated: 2017:08:29:11:33:15