I was writing a REST component but having difficulties when I do not want to pass argument for a parameter. My code and URL (PATH style) look like this.
Component definition:
<cfcomponent rest="true" restPath="SearchRestAPI">
<cffunction name="restaurantResults" access="remote" httpMethod="get"
output="false" returntype="Query" produces="application/json"
restPath="Search/{city : ([a-zA-Z])*}/{address}/{type}">
<cfargument name="city" default="" type="string" restargsource="path">
<cfargument name="address" default="" type="string" restargsource="path">
<cfargument name="type" default="" type="string" restargsource="path">
Calling URL/Path to consume the REST service. Notice I do not want to send any value for type parameter so there is double slash at the end of the path:
http://localhost:8502/backend/section/SearchResAPI/Search/Calcutta/Lindsay Street//
But this is throwing a "Not Found" error. Any suggestion would be highly appreciated.
I am not sure about this ColdFusion functionality, but looks like "restPath" works with regular expressions (which you are already using when capturing the city parameter
Similarly to the above, you could try:
Here is a ColdFusion page that has some examples as well (search the page for "restPath"): https://wikidocs.adobe.com/wiki/display/coldfusionen/cfcomponent