Charlie123 February 2016

HTTP/1.1 500 Complex object types cannot be converted to simple values

I'm following a tutorial by Ben Nadel and I am receiving the following error in browser Network/XHR.

Complex object types cannot be converted to simple values

I think the problem is in the CFLoop tag but I'm not sure exactly what I should modify to resolve the error.

<!---
    Get the content as a byte array (by converting it to binary,
    we can echo back the appropriate length as well as use it in
    the binary response stream.
--->
<cfset binResponse = ToBinary(ToBase64( objRequest.FileContent )) />

<!--- Echo back the response code. --->
<cfheader statuscode="#Val( objRequest.StatusCode )#" statustext="#ListRest( objRequest.StatusCode, ' ' )#" />

<!--- Echo back response legnth. --->
<cfheader name="content-length" value="#ArrayLen( binResponse )#" />

<!--- Echo back all response heaers. --->
<cfloop item="strKey" collection="#objRequest.ResponseHeader#">

<!--- Check to see if this header is a simple value. --->
    <cfif IsSimpleValue( objRequest.ResponseHeader[ strKey ] )>

        <!--- Echo back header value. --->
        <cfheader name="#strKey#" value="#objRequest.ResponseHeader[ strKey ]#" />
    </cfif>

</cfloop>

<!---
    Echo back content with the appropriate mime type. By using
    the Variable attribute, we will make sure that the content
    stream is reset and ONLY the given response will be returned.
--->
<cfcontent type="#objRequest.MimeType#" variable="#binResponse#" />

Answers


Charlie123 February 2016

I commented out each line of code until I found out that the problem line of code was the cfheader. It turned out, I don't even need the whole cfloop block of code. The author of this tutorial may have other use for this block of code but for what I do, it works fine without it. Many thanks for those who tried to help.

<cfheader name="#strKey#" value="#objRequest.ResponseHeader[ strKey ]#" />

Post Status

Asked in February 2016
Viewed 2,653 times
Voted 10
Answered 1 times

Search




Leave an answer