3 Replies Latest reply on Feb 11, 2016 8:34 AM by Steve Sommers

    How to log the rendered cfhttp URL?

    2Charlie Level 1

      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">

        • 1. Re: How to log the rendered cfhttp URL?
          WolfShade Level 4
          <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.

          • 2. Re: How to log the rendered cfhttp URL?
            2Charlie Level 1

            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>

            • 3. Re: How to log the rendered cfhttp URL?
              Steve Sommers Level 4

              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)