Downloading files from URLs with isapi extensions

Post Reply
cstevens
Member
Posts: 40
Joined: Tue Feb 12, 2013 8:42 pm

Downloading files from URLs with isapi extensions

Post 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.
User avatar
gabrielp
Advanced member
Posts: 577
Joined: Fri Aug 08, 2014 4:31 pm
Location: Boston
Contact:

Re: Downloading files from URLs with isapi extensions

Post 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.
Chat: open-automation @ gitter
Code: open-automation & dominickp @ GitHub
Tools: Switch, Pitstop, EPMS, Veracore, PageDNA, SmartStream, Metrix
dkelly
TOP CONTRIBUTOR
Posts: 628
Joined: Mon Nov 29, 2010 8:45 pm
Location: Alpharetta GA USA
Contact:

Re: Downloading files from URLs with isapi extensions

Post by dkelly »

Did you try e.download( source-url : String, destination-path : String ) : Boolean ?
cstevens
Member
Posts: 40
Joined: Tue Feb 12, 2013 8:42 pm

Re: Downloading files from URLs with isapi extensions

Post 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.
User avatar
gabrielp
Advanced member
Posts: 577
Joined: Fri Aug 08, 2014 4:31 pm
Location: Boston
Contact:

Re: Downloading files from URLs with isapi extensions

Post 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?
Chat: open-automation @ gitter
Code: open-automation & dominickp @ GitHub
Tools: Switch, Pitstop, EPMS, Veracore, PageDNA, SmartStream, Metrix
cstevens
Member
Posts: 40
Joined: Tue Feb 12, 2013 8:42 pm

Re: Downloading files from URLs with isapi extensions

Post 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.
User avatar
gabrielp
Advanced member
Posts: 577
Joined: Fri Aug 08, 2014 4:31 pm
Location: Boston
Contact:

Re: Downloading files from URLs with isapi extensions

Post by gabrielp »

Thanks for sharing your solution
Chat: open-automation @ gitter
Code: open-automation & dominickp @ GitHub
Tools: Switch, Pitstop, EPMS, Veracore, PageDNA, SmartStream, Metrix
Post Reply