ColdFusion 10中的PUT请求问题

时间:2014-03-07 07:17:02

标签: coldfusion coldfusion-10 cfhttp

在使用API​​时,我需要向URL发出PUT请求,同时需要将一些参数作为POST参数传递。

在本地我创建了2个文件calling.cfm和caller.cfm来测试带有PUT请求的cfhttp。 但每次抛出错误The request has exceeded the allowable time limit Tag: cfhttp

caller.cfm

<cfhttp url="http://cflocal.com/jquerySliderApp/calling.cfm" method="put">
     <cfhttpparam type="header" name="Content-Type" value="application/x-www-form- urlencoded; charset=UTF-8" />
     <cfhttpparam type="body" value="Deepak" >  
</cfhttp>   
<cfdump var="#cfhttp#">

calling.cfm

<cfloop collection="#FORM#" item="i">
   <cfoutput>FORM SCOPE:#form[i]#</cfoutput>
</cfloop>

<cfloop collection="#URL#" item="i">
  <cfoutput>URL SCOPE:#URL[i]#</cfoutput>
</cfloop>

我在Adobe Forum中传递带type="body"的参数,有人提到ColdFusion通过PUT和DELETE请求发送请求体,因此我们可以将请求体格式化为表单字段(或表格字段)。

我尝试了<cfhttpparam type="body" name="fname" value="#urlEncodedFormat("Deepak")#" >。仍然显示相同的错误。

我正在使用ColdFusion 10.如果我做错了,请告诉我。

1 个答案:

答案 0 :(得分:4)

当type =“body”时,

<cfhttpparam>对name属性不做任何事情。如果你自己设置身体,你应该发送像身体一样的东西:

fname=Deepak&otherparam=foo

通常情况如此,Ben Nadel has your back here。 CF不会在PUT或DELETE请求中为您处理FORM范围,因此您需要自己处理getHttpRequestData().content以获取发送的值,但您可以使用方法in this blog post实现这一点。