Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Return JSON data in response in ColdFusion

I'm working in ICIMS API. I need to return JSON data and some specific data in header in a cfm page call by ICIMS server.

Here is the response should be:

Response to the Work Flow Status Change PUSH event to the platform:

HTTP/1.1 303 See Other
Location: http://xx.xx.xx.xx:8085/selectpackage?systemHash=101
Content-Type: application/json
{
"userMessage":"Confirm or modify package.",
}

Thanks in advance.

Answer:

> <cfset contentString = '{"userMessage": "Confirm or modify package."}'
> />
> 
> <cfheader name="Location"
> value="http://xx.xx.xx.xx:8085/selectpackage?systemHash=101" />
>     <cfcontent type="application/json" variable="#toBinary( toBase64( contentString ) )#" />
like image 354
Roul Avatar asked Mar 28 '15 15:03

Roul


1 Answers

<cfheader 
    statusCode = "303"
    statusText = "See Other">

<cfheader 
    name="Location" 
    value="http://xx.xx.xx.xx:8085/selectpackage?systemHash=101">

<cfheader 
    name="Content-Type" 
    value="application/json">

<cfset foo = structNew()>
<cfset foo["userMessage"] = "Confirm or modify package.">

<cfoutput>#serializeJSON(foo)#</cfoutput>  
like image 194
Alex Baban Avatar answered Nov 03 '22 08:11

Alex Baban