Skip to main content
2Charlie
Inspiring
Feb 10, 2016 7:19 PM UTC
Question

How to log the rendered cfhttp URL?

I have this cfhttp tag.I want to log the URL to see if it's actually having all the correct parameters because it's not working.

<cfhttp result="objRequest" url="#UrlDecode( strTargetURL )#" method="#CGI.request_method#" useragent="#CGI.http_user_agent#" timeout="15">

    This topic is closed to new replies. Start a new post to keep the conversation going.

    3 replies

    WolfShade
    Legend
    Feb 10, 2016 9:17 PM UTC

    <cflog file="_TESTING" text="URL is: #UrlDecode( strTargetURL )#" application="yes" type="information" />

    After the code runs, open CFAdmin and go to your LOGS.  Look for the log called _TESTING.

    Although, I think that the URL should be UrlENcode() (encoding it for safe browser use.)

    V/r,

    ^_^

    PS:  This will get only the value of the FQDN URL, not a URI or any url parameters (unless you're manually setting parameters for the "strTargetURL" variable).  If you want those, you'll have to add:

    "?" & cgi.query_string

    after the URL.

    Translate
    2Charlie
    2CharlieAuthor
    Inspiring
    Feb 11, 2016 3:50 PM UTC

    Thanks but that does not show me the URL with all the parameters attached to it. Here's the whole cfhttp tag.

    <cfhttp result="objRequest" url="#UrlDecode( strTargetURL )#" method="#CGI.request_method#" useragent="#CGI.http_user_agent#" timeout="15">

        <!--- Add the referer that was passed-in. --->

        <cfhttpparam type="header" name="referer" value="#CGI.http_referer#" />

        <cfhttpparam type="url" name="apiKey" value="56a7d8c123131c4058389107">

        <cfhttpparam type="url" name="projectid" value="55c4ffd123131c527e456fe6">

        <cfhttpparam type="url" name="status[$in][]" value="published">

        <cfhttpparam type="url" name="status[$in][]" value="draft">

        

         <!--- Pass along any URL values. --->

        <cfloop item="strKey" collection="#URL#">

            <cfhttpparam type="url" name="phrase" value="#URL[strKey]#" />

        </cfloop> 

      

    </cfhttp>

    Translate
    Legend
    Feb 11, 2016 4:34 PM UTC

    You can easily dump out the request results with CFDUMP, but I have not found an easy way to dump out the request -- you'll have to log each parameter you want to view:

    <cflog file="#expandPath('..')#/_TESTING-REQUEST" text="URL: #UrlDecode( strTargetURL )#" application="yes" type="information" />

    <cflog file="#expandPath('..')#/_TESTING-REQUEST" text="apiKey: 56a7d8c123131c4058389107application="yes" type="information" />

    ...

    <cfdump var=#objRequest#" output="#expandPath('..')#/_TESTING-RESPONSE" />

    (you can combine entries as well)

    Translate