CF 在 cf2016 中接受 JSON 字符串,但在 cf9 中不接受
CF accepts JSON string in cf2016 but not in cf9
我正在调用一个 API 并需要向它发送一个带有凭据的 JSON 字符串。我们目前正在从 CF9 过渡到 CF2016。在 DEVL 中,我有两个版本。在测试和生产中,我目前只有 CF9。最初我编写了代码并在 CF2016 上进行了测试,它运行良好。当我将它推到测试时,它不起作用。我在 CF9 上的 DEVL 中重试,它也出错。代码是:
<cfset logininfo = {"username": "eistech", "password": "#sat_pw#"}>
<cfset fromdate=dateformat(DateAdd('d', -1, dat), "yyyy-MM-dd") & 'T00:00:00-0500'>
<!--- Get token info--->
<cfhttp url="https://scoresdownload.collegeboard.org/pascoredwnld/files/list?fromDate=#fromdate#" method="post" result="finfo">
<cfhttpparam name="Content-Type" type="HEADER" value="application/json">
<cfhttpparam name="Accept" type="HEADER" value="application/json">
<cfhttpparam type="body" value="#serializeJSON(logininfo)#">
</cfhttp>
在CF9中运行时,我得到:
Invalid CFML construct found on line 5 at column 20. ColdFusion was
looking at the following text:
{ (Line 20 is <cfset logininfo =
{"username": "eistech", "password": "#sat_pw#"}>
我尝试用单引号将它括起来,但这两种情况都失败了。我怎样才能让它在 CF2016 和 CF9 中工作?
CF9 不理解问题中 JSON 字符串中使用的 :
。
使用=
!
<cfset logininfo = {"username"= "eistech", "password"= "#sat_pw#"}>
我正在调用一个 API 并需要向它发送一个带有凭据的 JSON 字符串。我们目前正在从 CF9 过渡到 CF2016。在 DEVL 中,我有两个版本。在测试和生产中,我目前只有 CF9。最初我编写了代码并在 CF2016 上进行了测试,它运行良好。当我将它推到测试时,它不起作用。我在 CF9 上的 DEVL 中重试,它也出错。代码是:
<cfset logininfo = {"username": "eistech", "password": "#sat_pw#"}>
<cfset fromdate=dateformat(DateAdd('d', -1, dat), "yyyy-MM-dd") & 'T00:00:00-0500'>
<!--- Get token info--->
<cfhttp url="https://scoresdownload.collegeboard.org/pascoredwnld/files/list?fromDate=#fromdate#" method="post" result="finfo">
<cfhttpparam name="Content-Type" type="HEADER" value="application/json">
<cfhttpparam name="Accept" type="HEADER" value="application/json">
<cfhttpparam type="body" value="#serializeJSON(logininfo)#">
</cfhttp>
在CF9中运行时,我得到:
Invalid CFML construct found on line 5 at column 20. ColdFusion was looking at the following text:
{ (Line 20 is <cfset logininfo = {"username": "eistech", "password": "#sat_pw#"}>
我尝试用单引号将它括起来,但这两种情况都失败了。我怎样才能让它在 CF2016 和 CF9 中工作?
CF9 不理解问题中 JSON 字符串中使用的 :
。
使用=
!
<cfset logininfo = {"username"= "eistech", "password"= "#sat_pw#"}>