Empty POST requests

I am attempting to migrate to Lucee from ACF and have git a snag. I am using a third-party library so “just use GET” will not work. (I will also need to handle very large requests in other places so GET won’t work in any case.)

I have a CFC

<cffunction name="test" output="true" returnType="any" access="remote">
	<cfreturn 'this is a test'>
</cffunction>


$.ajax({
		url: "/component/utilities.cfc",
		type: "GET",
		data: {
			method:  "test"
		}
	});

works as expected.

Change GET to POST, and I get a zero-content 200 response. I have tried this with multiple methods and tools, and the result is always the same. A POST request to a static page works as expected. CFHTTP GET and POST both work as expected. ajax POST (and whatever’s built into http://www.jtable.org/) fail, everything else I can think of works. I can’t even imagine how this could be a Lucee problem, but that’s really all that’s changed in my environment. Any help is greatly appreciated!

Can you see that the method=“test” is in the form-data of the request? (with the browser-dev tool)
Or have tried to create the request via postman?

@dustymc, Could you please add a returnformat in cffunction? After then, I hope, you can get a response.

Yes of course, I’ve tried that hard-coded in the function (how CF works, and this will work in reality), in the URL, as a POST parameter…

Here’s a fresh grab with method and returnformat.

I’m apparently only allowed one image; the Response tab contains “No response data available for this request.”

I don’t have postman but as above other mechanisms work, it’s just the one thing that I’m forced to use by my environment that seems to be haunted. I tried curl and …


> POST /component/utilities.cfc HTTP/1.1
...
> Content-Length: 13

please always mention which version of Lucee your using!

wild guess, can u try adding this to your application.cfc?

this.bufferOutput = true;

version

Lucee 5.3.3.62

this.bufferOutput = true;

did not seem to change anything.

Just a quick guess; couldn’t it be a CORS issue? I remember something similar that I resolved by setting response headers,

<cfheader name="access-control-allow-origin" value="#app.allowedRemoteOriginHostname#">
<cfheader name="access-control-allow-credentials" value="true">
<cfheader name="access-control-allow-headers" value="Content-Type">

See this link her refering Access-Control-Allow response headers

Another thing that comes into my mind… did you set the correct content-type in your ajax request? E.g. “Content-Type”: “application/x-www-form-urlencoded” ?

$.ajax({
		url: "/component/utilities.cfc",
		type: "POST",
		headers: { 'content-type': 'application/x-www-form-urlencoded' },

		data: { somedata: 'test' }
	});