Warning: file_get_contents(/data/phpspider/zhask/data//catemap/0/mercurial/2.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
将json传递给cfhttpparam_Json_Coldfusion - Fatal编程技术网

将json传递给cfhttpparam

将json传递给cfhttpparam,json,coldfusion,Json,Coldfusion,我正在使用ColdFusion 2016,下面是我正在做的: <cfhttp method="put" url="https://www.colorfulapi.com/testpage/#arguments.Name#" username="#request.APIusername#" password="#request.APIToken#" result="results"> <cfhttpparam type="header" name="Content-Typ

我正在使用ColdFusion 2016,下面是我正在做的:

<cfhttp method="put" url="https://www.colorfulapi.com/testpage/#arguments.Name#" username="#request.APIusername#" password="#request.APIToken#" result="results">
    <cfhttpparam type="header" name="Content-Type" value="application/json">
    <cfif isStruct(arguments.structform) AND !StructIsEmpty(arguments.structform)>
    <CFHTTPPARAM VALUE="'#serializeJSON(stFields)#'" TYPE="body">
    </cfif>
  </cfhttp>
如果它使用
serializeJSON
进入cfhttpparam,它将显示以下内容:

"error":"JSON error: 822: unexpected token at ''{\"ONE\":{\"GROUP\":\"my  group\"}}''"}
我在POSTman中尝试了相同的代码,但在
POSTman
中,对于
JSOn
发送,我必须使用原始的正文,并选择内容作为
application/JSOn
,它在那里起作用

这就是我生成stfield的方式

<cfset stFields = StructNew()>
  <cfset stFields.one = arguments.structform>
  <cfdump var="'#serializeJSON(stFields)#'"> 

删除单引号:

<CFHTTPPARAM VALUE="#serializeJSON(stFields)#" TYPE="body">

不,不是Alex,让我写下如何生成
stFields
。我正在编辑我的问题如果我删除单个代码,我会得到一个错误,将json字符串传递给api是无效的,这让人很困惑,
{“ONE”:{“GROUP”:“my GROUP”}}
是无效的json<代码>{“一”:{“组”:“我的组”}另一方面,是。API到底期望什么?这是我从POSTMAN API发送的内容,它可以工作
http://prntscr.com/e72nxx
@weqsd-旧方法是使用结构表示法,而不是点表示法,即
structName[“keyName”]=value
。如果使用速记结构语法,请参见中的示例。另请参见CF11+中的更多选项。
<CFHTTPPARAM VALUE="#serializeJSON(stFields)#" TYPE="body">
<CFHTTPPARAM VALUE="#stFields#" TYPE="body">