ColdFusion 10 中的 PUT 请求问题 [英] Issue with PUT request in ColdFusion 10
问题描述
在使用 API 时,我需要向 URL 发出 PUT
请求,并且需要将一些参数作为 POST 参数传递.
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.
我在本地创建了 2 个文件 call.cfm 和 caller.cfm 来使用 PUT
请求测试 cfhttp.但是每次都抛出错误 The request has exceeded the allowed time limit Tag: cfhttp
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
调用者.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#">
调用.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 论坛中使用 type="body"
传递参数 ,有人提到 ColdFusion 发送请求正文时带有 PUT 和 DELETE 请求,因此我们可以将请求正文格式化为表单字段(或一系列表单字段).
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).
我已尝试使用 <cfhttpparam type="body" name="fname" value="#urlEncodedFormat("Deepak")#" >
.仍然显示相同的错误.
I have tried with <cfhttpparam type="body" name="fname" value="#urlEncodedFormat("Deepak")#" >
. Still showing the same error.
我正在使用 ColdFusion 10.如果我做错了什么,请告诉我.
I am using ColdFusion 10. Please let me know if i am doing something wrong.
推荐答案
<cfhttpparam>
在 type="body" 时不会对 name 属性做任何事情.如果您自己设置正文,您应该发送如下内容作为正文:
<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
通常情况下,Ben Nadel 支持你.CF 不会为您处理 PUT 或 DELETE 请求的 FORM 范围,因此您需要自己处理 getHttpRequestData().content
以获取发送的值,但您可能可以使用这篇博文的方法来实现这一点.
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屋!