Sunday, 15 March 2015

How to pass parameter in Form Scope for REST services in ColdFusion? -



How to pass parameter in Form Scope for REST services in ColdFusion? -

today while working coldfusion 10 rest, got issues. not sure how pass info rest service in form scope. here rest enabled cfc,

<cfcomponent rest="true" restpath="/crudservice" > <cfset variable.myquery = querynew("id,name","integer,varchar",[[1,"test1"],[2,"test2"],[3,"test3"]] )> <cffunction name="gethandlerjsonform" access="remote" httpmethod="get" restpath="/formtest" returntype="query" produces="application/xml"> <cfargument name="customerid" required="true" restargsource="form" type="numeric" > <cfquery dbtype="query" name="local.qrygetusername"> select name variable.myquery id = <cfqueryparam cfsqltype="cf_sql_integer" value="#customerid#"> </cfquery> <cfreturn local.qrygetusername> </cffunction> </cfcomponent>

here cfm code, calling rest service,

<cfset restinitapplication("e:\local workspace\cfcs\rest","myfirstrest")> <cfhttp url="http://cflocal.com/rest/myfirstrest/crudservice/formtest" method="get" > <cfhttpparam type="header" name="content-type" value="application/x-www-form-urlencoded" > <cfhttpparam type="formfield" name="customerid" value="1" > </cfhttp> <cfdump var="#cfhttp#">

in statuscode getting 500 exception obtaining parameters ?

please suggest whats going wrong here.

rest coldfusion coldfusion-10

No comments:

Post a Comment