Issue with PUT request in ColdFusion 10

流过昼夜 提交于 2019-12-24 03:21:02

问题


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.


回答1:


<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.



来源:https://stackoverflow.com/questions/22243896/issue-with-put-request-in-coldfusion-10

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!