I am getting a response from Coldbox API in ColdFusion but I am unable to convert this response to PDF in Coldfusion. I have attached an image of the response below.
Here is my code:
<cfhttp result="get" method="POST" url="https://content.dropboxapi.com/2/files/download" getAsBinary="yes" >
<cfhttpparam type="header"name="Authorization" value="#token#">
<cfhttpparam type="header" name="Dropbox-API-Arg" value="#serializeJSON(pathData)#">
</cfhttp>
<cfheader name="content-disposition" value="inline; filename=test.pdf" />
<cfheader name="content-transfer-encoding" value="binary" />
<cfcontent type="application/pdf" variable="#get.Filecontent#" reset="true" />
I want to Hit API and download the file in next tab.
Let me know If anyone can help me to fix that issue.
Thanks.
I am getting a list of product ID periodically, and I call these dynamic pages using cfhttp and save the received response as html file in root folder
my script may look like
<cfloop list="#productlist# index="productid" >
<cfhttp url="//domainname.com" result="result" charset="utf-8">
<cfhttpparam type="formfield" name="productid" value="#productid#">
</cfhttp>
<cfset content = result.filecontent>
<cffile action="write" file="#filename#" output="#trim(content)#" />
</cfloop>
Is there any better or optimized way to achive this result?
I am trying to retrieve the signed documents from Docusign - and save the PDF file locally.
I have tried multiple ways to attempt to extract the PDF out of the returned cfhttp data.
Seems I can get the correct number of pages in the PDF document I download - but they view as all blank with messages of invalid signature.
My guess is that I am not parsing multiple PDF files from the filecontent in the returned cfhttp variable but not finding how to do this anywhere.
My current code is similar to:
<cfhttp url="https://demo.docusign.net/restapi/v2/accounts/#variables.ACCOUNT#/envelopes/#url.ENVELOPE_ID#/documents/combined" method="GET" resolveurl="Yes" throwonerror="No" result="MY_INFO">
<cfhttpparam name="X-DocuSign-Authentication" type="HEADER" value="<DocuSignCredentials><Username>#variables.userName#</Username><Password>#variables.password#</Password><IntegratorKey>#variables.integratorKey#</IntegratorKey></DocuSignCredentials>">
<cfhttpparam name="Content-Type" type="HEADER" value="application/json">
<cfhttpparam name="Accept" type="HEADER" value="application/json">
</cfhttp>
<cffile action="write" file="D:\Inetpub\Wwwroot\docusign\completed\mypdf.pdf" output="#TRIM(MY_INFO.FileContent)#">
Following up here, based on your comments you've solved this:
"Instead of trying to write the file via the cffile - i added
path="D:\Inetpub\Wwwroot\docusign\completed\" file="#variables.FILE_NAME#"
to the cfhttp call"
I have a cfc that makes a call to a remote service using cfhttp. The service is returning a failure code, which means that my call to the remote service is not formatted properly. Is there any way to capture the content of a cfhttp post I'm sending? I want to capture the raw post data so I can see where my formatting problem is. Here is a sample of what my code looks like:
<cfhttp url="https://www.webservice.com" method="POST" result="httpResponse">
<cfhttpparam type="formField" name="method" value="doSomething">
<cfhttpparam type="formField" name="user" value="myUserName">
<cfhttpparam type="formField" name="password" value="myPassword">
</cfhttp>
I'd like to do something like this:
<cfset result = structNew() />
<cfset result["response"] = httpResponse />
<cfset result["sentContent"] = cfhttp.sentContent />
Is it possible to get the content of a sent cfhttp without looking at the server logs. My server is offsite and getting the logs will be a PITA.
You could create a template to which you would POST to. That template could return the result of GetHttpRequestData() function.
I have used this:
Generate Google Analytics events (__utm.gif requests) serverside
and this:
http://www.garyrgilbert.com/blog/index.cfm/2008/10/21/Tracking-Digital-Content
to build a cfhttp string so that when a user hits a page it calls google analytics. I'm doing it like this because the pages I'm serving are XML pages and I can't mix javascript with xml.
My problem is that google analytics is ignoring my requests. I have activated my bucket code on a normal html server, so it thinks/knows it exists, but now when i call any of my xml server pages and make the cfhttp request from coldfusion server, it doesn't get registered.
Update:
Following Sergii advice, I have done a dump to find out what the cfhttp is doing (i was previously missing a variable which was causing it to error), i am now getting a http return of 200, though analytics is not applying the request to my account.
Update the 2nd, including code:
<cfset var_utmac='UA-myUA'> <!--- enter the new urchin code --->
<cfset var_utmhn='www.myaddress.co.uk'>
<cfset var_utmn = RandRange(10000000,99999999)>
<cfset var_cookie = RandRange(10000000,99999999)>
<cfset var_random = RandRange(1000000000,2147483647)>
<cfset var_today = now()>
<cfset var_referer = #cgi.HTTP_REFERER#>
<cfset var_uservar = 'jevans'>
<cfset var_utmp= ''>
<cfset apiname = 'listings.getlistings'>
<cfhttp method="get" url="http://www.google-analytics.com/__utm.gif">
<cfhttpparam type="url" name="utmwv" value="1" />
<cfhttpparam type="url" name="utmn" value="#var_utmn#" />
<cfhttpparam type="url" name="utmsr" value="-" />
<cfhttpparam type="url" name="utmsc" value="-" />
<cfhttpparam type="url" name="utmul" value="-" />
<cfhttpparam type="url" name="utmje" value="0" />
<cfhttpparam type="url" name="utmfl" value="-" />
<cfhttpparam type="url" name="utmdt" value="#apiName#" />
<cfhttpparam type="url" name="utmhn" value="#var_utmhn#" />
<cfhttpparam type="url" name="utmr" value="#var_referer#" />
<cfhttpparam type="url" name="utmp" value="#var_utmp#" />
<cfhttpparam type="url" name="utmac" value="#var_utmac#" />
<cfhttpparam type="url" name="utmcc" value="__utma%3D#var_cookie#.#var_random#.#var_today#.#var_today#.#var_today#.2%3B%2B__utmb%3D#var_cookie#%3B%2B__utmc%3D#var_cookie#%3B%2B__utmz%3D#var_cookie#.#var_today#.2.2.utmccn%3D(direct)%7Cutmcsr%3D(direct)%7Cutmcmd%3D(none)%3B%2B__utmv%3D#var_cookie#.#var_uservar#%3B" />
</cfhttp>
any thoughts?
cheers
Looking at your code, I'm guessing that you need to replace &'s in your code with regular & symbols. You only need to escape the ampersands to validate XML documents and such. If you send them over the URL, then they may not be recognized as separators.
I would actually construct it like so:
<cfhttp method="get" url="http://www.google-analytics.com/__utm.gif">
<cfhttpparam type="url" name="utmwv" value="5.1.2" />
<cfhttpparam type="url" name="utmn" value="#var_utmn#" />
... all your other URL variables
<cfhttp>
This will make your code a little easier to read, as well as make sure that all of your variables are sent over in the property format, without needing to concatenate a huge string.
It looks like several of your parameters should be of different types. You are sending them all as URL parameters. Should, for example, the HTTP_REFERER be sent as type="CGI".
Looking at my own GA HTTP, I see that in my URL string that I have utmr=-
But the request is also sending along a CGI header for Referer: http://12robots.com/
Maybe try adding another param with type="CGI" name="HTTP_REFERER" value="#CGI.HTTP_REFERER#"
You might want to look at how it is being done in this PHP class and see if you can adapt it to your ColdFusion code. It looks like it might be more than a few URl params that need setting. It is likely that you need to better simulate a real browser to make GA think you are a real browser.
http://code.google.com/p/serversidegoogleanalytics/
Pretty sure cfset var_today = now() is wrong. GA has no idea what a ColdFusion date/time object is