Unable to run this file REST Class file in USER Namespace
Hi, I tried the new rest file in User namespace. But I couldn't run it.
Here the Code:
Class com.Testing Extends %CSP.REST { XData UrlMap { <Routes> <Route Url="/insert" Method="POST" Call="one"/> <Route Url="/print" Method="POST" Call="two"/> <Route Url="/update" Method="POST" Call="three"/> </Routes> } ClassMethod one() { Write "This is 1st Method!!" Quit } ClassMethod two() { Write !,"This is 2nd method" Quit } ClassMethod three() { Write !,"This is 3rd Method" Quit } }
I tried it in the below link:
http://localhost:57772/csp/user/testing/insert
Can anyone help me resolve this error?
Looks like you forgot to define web application for your REST Service. Please look at the documentation. And at this part:
Amplifying what Dmitry wrote, here's the web app I defined to make your example class work:
I also had to change your classmethods so they Quit $$$OK instead of simply quitting.
And to test from the browser I used http://localhost:57772/csp/user/testing/print because that's the route you have defined as accepting the GET method from the browser.
There's a REST sample (REST.DocServer) in the SAMPLES namespace. To use it you need to enable the /csp/samples/docserver web application by setting this checkbox:
Then this URL will return the source of the Cinema.Review class from the SAMPLES namespace:
http://localhost:57772/csp/samples/docserver/class/samples/Cinema.Review
Given that this REST sample will return the source of any class from any namespace, it's understandable that the /csp/samples/docserver application is disabled by default on a new installation.
Thanks Dmitry and John
I missed the Dispatch Class
Glad to have helped. Please click the checkmark alongside one of the answers so that the question no longer lists as "unanswered".
In addiction to that answer, don't forget to set the Application Role to %All (or other role that you need), or it always returns a "Forbidden" error.
Best regards,
Francisco