Copy link to clipboard
Copied
I cannot seem to get my REST service to work... I get a 404 when I call the URL. Im running Win 7, CF 10 developer, Apache webserver. I've developed on this for years, so the setup works - but this is my first go at REST services thru CF... I mention that because CF is working, the dir and webserver are working etc. Directory looks like this C:\wwwroot\restTest CODE - saved as "obj1.cfc" - ( Note: I've tried restpath with and without the / ) The coldfusion ADMIN setup looks like this I'm using the service mapping because I don't have an associated application name - no Application.cfc - I was trying to keep this super simple. I get a green 'success' message when I set that path Browse to - result - 404 What am I doing wrong? It is my understanding that "/rest/" is a default mapped path in CF for routing the service - I may be wrong, but I know I read it somewhere - and the examples all use it. I also believe I can change that either in the admin or in some XML file... |
Copy link to clipboard
Copied
C:\wwwroot\restTest
Move the directory to a location under the webroot, and it should then work.
Copy link to clipboard
Copied
@BKBK - it is under the web root - I thought c:\wwwroot would be clear on that - my apache is mapped to c:\wwwroot..
Are you trying to say that is HAS to be under the CF default webroot??? because THAT seems 'propriatary' and silly -
As a production site would rarely (never, that I've seen) use CFs webserver - apache, or IIS or any other has their own root location
and mappings occure.
Copy link to clipboard
Copied
jpmyob wrote:
... Are you trying to say that is HAS to be under the CF default webroot???
No. I was just suggesting the simplest way to get REST working. Incidentally, by 'webroot' I mean webroot, not 'CF default webroot'.
I agree with you that any path to a directory containing a REST-enabled CFC should work. Let's debug your settings, one by one.
Directory looks like this
C:\wwwroot\restTest
CODE - saved as "obj1.cfc" - ( Note: I've tried restpath with and without the / )
<cfcomponent restpath="/restTest" rest="true" >
<cffunction name="getMethod" access="remote"
returntype="String" httpmethod="GET" >
<cfreturn "this is a string returned" />
</cffunction>
</cfcomponent>
That is OK. However, try testing the alternative, <cfcomponent restpath="/myRestPath">. I remember once encountering some difficulties with both restpath and rest. For clarity, at least, you should also distinguish the directory name from the restpath name, hence myRestPath.
The coldfusion ADMIN setup looks like this
Root path: 'C:\wwwroot\restTest' Service Mapping: 'test'
That is OK, too. Now, to start anew, go to the Caching page of the ColdFusion Administrator and press the button to 'Clear Component Cache Now'.
Restart ColdFusion. Create and run a CFM page containing the following code:
<!--- Maintain case-sensitivity in the URL, just in case. Pun unintended--->
<cfhttp url="http://localhost/rest/test/myRestPath" method="get" result="restResult">
</cfhttp>
<cfdump var="#restResult#">
Get ready! An upgraded Adobe Community experience is coming in January.
Learn more