I'm working with a service provider that stores .wav audio files that my application needs to retrieve. I make a service call which returns a URL to the audio file I need. I then attempt to use cfhttp to retrieve the file, and run into problems.
The URL looks something like:
<cfhttp url="#thisFileUrl#" getAsBinary = "no" method="GET" throwOnError="no" useragent="Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/90.0.4430.212 Safari/537.36 Edg/90.0.818.62" timeout="15" file="myFile.wav" path="C:\inetpub\wwwroot\ccAudio4_client\" > <cfhttpparam type="header" name="Connection" value="keep-alive" /> <!---<cfhttpparam type="Header" name="Accept" value="audio/wav;audio/x-wav;image/svg+xml">---> </cfhttp>
When I do not include the userAgent attribute, I get a "com/novell/ldap/LDAPException" error in the application.log file. If I do include the userAgent attribute as show above, the cfhttp tag hangs.
I can use a browser on our CF server's desktop and play the wav file via the URL, so it doesn't seem to be a permissions or firewall issue.
Running CF 2018 on IIS.
I've tried every combination of the cfhttp tag / attributes I can with no help. I'm able to use CFHTTP as expected for other URLs.
Any ideas would be greatly apreciated.
Cfhttpparam tags are usually necessary when you do a POST request. Not when you do a GET.
Let us assume that thisFileUrl is the download link of the WAV file. The file is of binary type. ColdFusion uses UTF-8 charset by default. But it won't hurt to add it as charset attribute.
Hence, the following GET request should download the file and store it as C:\inetpub\wwwroot\ccAudio4_client\myFile.wav:
<cfhttp url="#thisFileUrl#" getAsBinary="yes" method="GET" throwOnError="no" useragent="Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/90.0.4430.212 Safari/537.36 Edg/90.0.818.62" timeout="15" file="myFile.wav" charset="UTF-8" path="C:\inetpub\wwwroot\ccAudio4_client\" />