Adobe Solution Partner

August 5, 2010

Integrating ColdFusion with FogBugz results in cfhttp conx failure

Filed under: ColdFusion, General Development, JVM & Java — Nat Papovich @ 3:13 pm

The development team at Webapper has been using FogBugz for a couple years now and we like it well enough not to bother switching to anything else. One thing I found lacking is a “customer portal” – a way for our clients to review the status of open tickets we’re tracking for their projects. Our old system, OnTime, had this feature and it seems pretty basic. FogBugz does have a weak “anonymous user” feature but it doesn’t work how we need it to work. So we built a custom ColdFusion front-end using the FogBugz API. It has its own user table and user-project table, and the rest is just calls to FogBugz for tickets in a project, details about a ticket, etc.

But I encountered an issue right away, using cfhttp to call the FogBugz API. Here is the code I tried:

<cfhttp method="get" url="https://webapper.fogbugz.com/api.asp"></cfhttp>
<cfdump var="#cfhttp.FileContent#">

I kept getting “Connection Failure”. If you’re familiar with the FogBugz API (or if not but you have a good imagination and can take a guess what that URL might do) you might notice I’m not even doing an “action”. You can even try that URL in a browser and see that it displays a message about not being logged in, which is a response from the API. I wasn’t even getting that far. It’s like there was some invisible wall in between my cfhttp call and the API.

Because calls to the FogBugz API need to run over SSL, I thought I had to add the cert to the cacerts store in my JRE to make the SSL bit work. That took a while to do since I’m on a mac and the cacerts never looked right. Eventually though I got a cert added, but the cfhttp call still wouldn’t work. I never did figure out what the root cause was, but I did work around it.

I wrote some java code to do the job:

objUrl = createobject("java","java.net.URL").init("#local.baseURL#&amp;#local.queryString#");
conn = objUrl.openConnection();
...followed by some InputStreamReader and BufferedReader to get the output.

And now it works. So I know my cacerts thing is right and it’s a deficiency in cfhttp itself. What, I can’t be sure, but I don’t care. So if you’re struggling with ColdFusion and FogBugz integration using cfhttp, try this instead. And if you have gotten cfhttp to work with the FogBugz API, please share your code!

Share and Enjoy:
  • Digg
  • del.icio.us
  • Facebook
  • Google Bookmarks
  • LinkedIn
  • StumbleUpon
  • Technorati
  • TwitThis

2 Comments »

  1. I have recently heard a report that the JRE v 1.6 Update 20 causes issues with cfhttp over SSL. The current version of Java on the Mac is update 20. So this might be a JRE issue vs. a ColdFusion issue. Have you tried it on a machine that is not using Update 20?

    Since Apple does not trust us to update our own JRE, we may be pretty much hosed until they get around to updating us to Update 21 (maybe after update 22 is released).

    I do not know that Update 21 fixes the problem, but I would say, if you can, try this out on a Windows machine with something other than 1.6_20 and see what happens.

    Comment by Jason Dean — August 7, 2010 @ 11:21 am

  2. Interesting idea Jason, I have not tried it. If I do, I will let you know.

    Comment by Nat Papovich — August 7, 2010 @ 12:29 pm

RSS feed for comments on this post. TrackBack URL

Leave a comment

 

Server Down?

Maximize Web application uptime by drawing upon Webapper's years of experience tuning and stabilizing many of the world's largest ColdFusion Web applications. Contact us today!