• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 684
  • Last Modified:

cfhttp.filecontent is empty

I'm getting transactions back that appear to be blank using cfhttp.filecontent.  How can redirect my logic in coldfusion if cfhttp.filecontent comes back as empty?
0
COwebmaster
Asked:
COwebmaster
  • 6
  • 4
2 Solutions
 
azadisaryevCommented:
it may look empty when you output/dump it, but it in fact may contain whitespace characters like space(s).

so best check would be
<cfif len(trim(cfhttp.filecontent))>
<!--- it is not empty --->
<cfelse>
<!--- filecontent is empty --->
</cfif>

Azadi
0
 
COwebmasterAuthor Commented:
Azadi, using cfhttp.filecontent, I need to grab the second to last value at the end of it.  How would I do that?
0
 
azadisaryevCommented:
treat it as a list delimited by whatever is between the values (commas? spaces?)

assuming the values are separated (delimited) by spaces, you can use this to get the second-to-last value:

#listGetAt(cfhttp.filecontent, listLen(cfhttp.filecontent, " ")-1, " ")#

Azadi
0
Important Lessons on Recovering from Petya

In their most recent webinar, Skyport Systems explores ways to isolate and protect critical databases to keep the core of your company safe from harm.

 
COwebmasterAuthor Commented:
just tried that got the word 'box' for that value.  It should be 'approved' or 'declined'.
0
 
COwebmasterAuthor Commented:
actually, 'Box' is part of the users address.  so, . P.O. Box 14 ..which is the 10th value in from the left.  The value I need is second to the far right.  Yes, it appears spaces are the delimiter
0
 
COwebmasterAuthor Commented:
Actually, I found this code..

<cfset string = "#cfhttp.filecontent#">
<cfset delim = "=">
<!--- <cfset results = {}> --->
<cfloop list="#string#" index="pair" delimiters="&">
    <cfif listLen(pair, delim) gte 2>
       <cfset name = listFirst(pair, delim) >
       <cfset value = listLast(pair, delim) >
       <cfset results[name] = value>
    </cfif>
</cfloop>
<cfdump var="#results#">

How can use it to grab that second to last value?  Also, it errors on those {} so I commented it out.
0
 
azadisaryevCommented:
are you 100% sure that cfhttp.filecontent will ALWAYS have that value as second from the right?

what if the address part does not include 'P.O. Box' text?
or has it as 'P O Box' or as 'P.O.Box'? what if PO Box number includes a space like 'P.O. Box 777 A'?

what exactly do you need to do?
maybe just checking if filecontent contains 'approved' will be enough?

Azadi

0
 
azadisaryevCommented:
can you post yout cfhttp.filecontent here?
it will be a lot more helpful to see its content then to keep guessing what it may be...

Azadi
0
 
COwebmasterAuthor Commented:
Actually, I'll use filecontent contains 'approved' .  works great!
0
 
_agx_Commented:
> I'll use filecontent contains 'approved' .  works great!

    Use contains for what?  Be very careful using CONTAINS since it often matches more
    than you want it to ...

> Also, it errors on those {} so I commented it out.
   Then you're running on MX7 or earlier.  The "{}" is CF8 specific. For MX7 use structNew()

   <cfset results = structNew() > 

0
 
COwebmasterAuthor Commented:
Thanks!
0

Featured Post

Free Tool: SSL Checker

Scans your site and returns information about your SSL implementation and certificate. Helpful for debugging and validating your SSL configuration.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

  • 6
  • 4
Tackle projects and never again get stuck behind a technical roadblock.
Join Now