REST - 404 Not Found

后端 未结 1 1885
粉色の甜心
粉色の甜心 2021-01-14 10:07

I am playing with ColdFusion 10\'s RESTful web services. First, I registered a rest service via CF admin.

C:/ColdFusion10/cfusion/wwwroot/restful/ and called it IIT

1条回答
  •  粉色の甜心
    2021-01-14 10:50

    You are making two very minor mistakes. The first is that you are providing the restpath="IIT" in the CFC, but are then trying to use "restTest" in the URL. With restpath="IIT", the URL would be "IIT/IIT", not "IIT/restTest". Here is what the component definition should be if you are wanting to use "IIT/restTest" in the URL:

    
     
     
         
         
         
            select * from myQuery 
            where id = #arguments.customerID# 
         
         
     
      
    

    The second mistake you are making is that your CFHTTP call is including the name of the method. This is not how to use CF rest services. Here is the proper way to call in your CFM file:

       
        
    
    
    

    Also, I dropped off the port="8500" parameter as you specify the port in the URL already.

    Important note: Once you make any modification to the CFC file, make sure you go to the Administrator and reload your REST service by clicking on the Refresh icon!

    For completeness, I have the above code working locally on CF10, and here is the returned JSON:

    {"COLUMNS":["ID","NAME"],"DATA":[[1,"Sagar"]]}
    

    0 讨论(0)
提交回复
热议问题