Page 1 of 1

Downloading files from URLs with isapi extensions

Posted: Wed Sep 30, 2015 11:42 pm
by cstevens
Anyone had any luck using the HTTP scripting class to download files from an IIS server using isapi extensions? Something like this:

http://Server/path/filename.pdf?isapi=l ... cesIk5E6c=

I keep getting 406 errors with the description: HTTP GET request error: HTTP protocol error. 406 Not Acceptable.

Pasting the URL into a web browser opens the file with no issues.

Re: Downloading files from URLs with isapi extensions

Posted: Thu Oct 01, 2015 3:22 pm
by gabrielp
I haven't used it, but if I were you, I'd look at the HTTP response to see what is different about it. A program like Postman should show you the response headers, as Switch would see it.

Re: Downloading files from URLs with isapi extensions

Posted: Thu Oct 01, 2015 3:44 pm
by dkelly
Did you try e.download( source-url : String, destination-path : String ) : Boolean ?

Re: Downloading files from URLs with isapi extensions

Posted: Thu Oct 01, 2015 6:11 pm
by cstevens
s.download works fine. I was hoping to have the additional flexibility of the HTTP client, but this might do for a workaround.

I also tried Postman without any headers or authorization and it worked fine as well. I don't see anything in the response headers that would be concerning:

Accept-Ranges → bytes
Age → 0
Connection → Keep-Alive
Content-Length → 1656695
Content-Type → application/pdf
Date → Thu, 01 Oct 2015 13:55:41 GMT
ETag → "d06d801aaefbd01:0"
Last-Modified → Wed, 30 Sep 2015 18:30:38 GMT
Proxy-Connection → Keep-Alive
Server → Microsoft-IIS/7.5
X-Powered-By → ASP.NET
X-UA-Compatible → IE=EmulateIE7

I'm not sure what's going on with the HTTP client. I'm not changing any headers or authorization prior to calling the HTTP.get() command.

Re: Downloading files from URLs with isapi extensions

Posted: Thu Oct 01, 2015 6:39 pm
by gabrielp
Seems like a 406 is usually when a client can't accept the mime type of the response. So perhaps you need to tell the HTTP client to expect application/pdf somehow?

Re: Downloading files from URLs with isapi extensions

Posted: Thu Oct 01, 2015 8:32 pm
by cstevens
That was it. I forgot I was setting an Accept header earlier in the code to force a REST call to respond with XML. Doing a HTTP.resetHeaders() fixed the issue.

Thanks for the help both of you.

Re: Downloading files from URLs with isapi extensions

Posted: Thu Oct 01, 2015 8:43 pm
by gabrielp
Thanks for sharing your solution