· Jun 17, 2019

REST Beginner Question


I am taking some intro lessons in REST from the online courses. Below is a very simple code i wrote. But when i try to see the output by entering the url

http://localhost:57773/rest/coffeemakerapp/coffeemaker i get an error "

This page isn’t working

If the problem continues, contact the site owner.




 Class demo.CoffeeMakerRestServer Extends %CSP.REST
XData UrlMap [ XMLNamespace = "" ]
<Route Url="/coffeemaker" Method="GET" Call="GetCoffeeMakerInfo"/>

ClassMethod GetCoffeeMakerInfo() As %Status
Set tArr=[]
Do tArr.%PUSH({
"img": "txt",
"Name": "Best"
Write tArr.%ToJSON() 
Quit $$$OK

Discussion (7)0
Log in or sign up to continue

I would suggest that adding the %All role, though it would work, is a bit like crushing a nut with a sledgehammer. It effectively opens the door to any unwanted intruder to gain access the Cache/Ensemble/IRIS. For the purposes of a demo test application %All role will work however the deve;loper should be aware that there are more appropriate security mechanisms available to handle user authentication.

You could also try a tool like Postman to test service calls and authentication methods.  If you tick the Password checkbox it enables Basic authentication (plain text username/password) is enabled. You can  also use bearer tokens instead, which is a popular authentication scheme.

While authentication/authorization isn't really covered in great detail, REST and Relaxation is a good starting point for REST development and it comes with a video and source code.

You should also double-check your URL is correct and resource permissions are correct. You probably only need permissions on the ENSEMBLE namespace and there might be a resource that defines this. Your URL is probably something like http://yourserver/rest/coffeemakerapp/coffeemaker