在ColdFusion 10中有PUT请求的问题 [英] Issue with PUT request in ColdFusion 10
问题描述
使用API时,我需要向网址发出 PUT
请求,以及一些参数需要作为POST参数传递。
在本地,我创建了两个文件calls.cfm和caller.cfm来测试cfhttp与 PUT
请求。
但每次它抛出的错误请求已超过允许的时间限制标签:cfhttp
caller.cfm
< cfhttp url =http://cflocal.com/jquerySliderApp/calling.cfmmethod = put>
< cfhttpparam type =headername =Content-Typevalue =application / x-www-form- urlencoded; charset = UTF-8/>
< cfhttpparam type =bodyvalue =Deepak>
< / cfhttp>
< cfdump var =#cfhttp#>
calls.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>
我传递参数 type =body
,如 Adobe Forum 中所述,有人提到ColdFusion会使用PUT和DELETE请求发送请求正文,因此我们可以将请求正文格式化为表单字段(或一系列表单字段)。
我已经尝试过< cfhttpparam type = bodyname =fnamevalue =#urlEncodedFormat(Deepak)#>
。仍然显示相同的错误。
我使用ColdFusion 10.请让我知道如果我做错了。
fname = Deepak& otherparam = foo
由于经常出现这种情况, Ben Nadel有你的回来< a>。 CF不会为您处理PUT或DELETE请求的FORM范围,因此您需要处理 getHttpRequestData()。content
自己为了得到发送的值,但您可以使用本博文中的方法来实现。
While working with a API , I need to make a PUT
request to a URL along with some parameters needs to be passed as POST parameter.
Locally I have created 2 files calling.cfm and caller.cfm to test cfhttp with PUT
request.
But each time it is throwing error 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>
I am passing the parameter with type="body"
as in Adobe Forum , someone mentioned ColdFusion sends the request body with PUT and DELETE requests, so we can format the request body as a form field (or series of form fields).
I have tried with <cfhttpparam type="body" name="fname" value="#urlEncodedFormat("Deepak")#" >
. Still showing the same error.
I am using ColdFusion 10. Please let me know if i am doing something wrong.
<cfhttpparam>
doesn't do anything with the name attribute when the type="body". If you're setting the body yourself, you should be sending something like the following as the body:
fname=Deepak&otherparam=foo
As is so often the case, Ben Nadel has your back here. CF Doesn't process the FORM scope for you on PUT or DELETE requests, so you'll need to process getHttpRequestData().content
yourself in order to get at the values sent, but you can probably use the method in this blog post to achieve that.
这篇关于在ColdFusion 10中有PUT请求的问题的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!