I can’t say what’s wrong with your code or environmental issues causing the problem. However, I was just working on something similar. Here’s how I (would) set up code to perform the REST functionality.
Let’s first get some possible misunderstandings out of the way. That should perhaps be return arguments.ateat instead of return ateat. Just a matter of correctness because, in any case, Lucee will likely ignore your argument in favour of the one posted to the API. Also, the function’s return-type should probably be specified. However, these are not the cause of the issue.
Like @x999 , I suspect that what you have shown is caused by an environmental variable that was posted to the API. I arrived at that conclusion as follows.
I used your data and did the following REST test on Lucee 5.4.2.17. Everything worked as expected.
// The file /ROOT/restTest/Application.cfc
component {
// set a name for the REST application:
this.name = "myRestApplication";
this.webAdminPassword="my_admin_password";
public boolean function onApplicationStart()
{
// Define a REST service with same name as the application
restInitApplication(
dirPath=getDirectoryFromPath(getCurrentTemplatePath()),
serviceMapping=this.name,
password="my_admin_password"
);
return true;
}
public boolean function onRequestStart()
{
return true;
}
}
<!--- File /ROOT/restTest/TestComp.cfc --->
<cfcomponent rest="true" restpath="/test">
<!--- @hint: path of REST call = /rest/myRestApplication/test/testIt,
where myRestApplication = name of REST api as set in Application.cfc.
--->
<cffunction httpmethod = "POST" name="testFunc" access="remote" output="false" restpath="testIt">
<cfargument name="ateat" type="string" >
<cfreturn ateat>
</cffunction>
</cfcomponent>
<!--- CFM page to call REST API: /ROOT/restTest/callToTestRestApi.cfm --->
<cfhttp
url="http://localhost:8888/rest/myRestApplication/test/testIt"
method="POST"
result="result">
<cfhttpparam name="ateat" value="6" type="formfield">
</cfhttp>
<cfdump var = "#result#" label="REST Test Result">
I used cfargument in my test. The value posted in the form is 6. What the API returns is not just the field name, but the string “ateat=6”. I think the explanation for that is: the default return-format is JSON.
I have just repeated the test, omitting the cfargument line this time. The value posted in the form is again 6. The return value this time is “6”, in contrast to “ateat=6” in the previous test.