Question
· Sep 22, 2019

How to run REST API through browser

Hello friends,

I am trying to create REST API in Cache. I am getting a response from postman but when I tried to launch the same URL on the browser, I am getting service unavailable error.

This is my URL
http://localhost:57772/widgetsdirect/rest/Gunwant

Any help is greatly appreciated.

Thanks and Regards,
Gunwant Kapade

Discussion (11)2
Log in or sign up to continue

Sure Danny, I will do that.

This is my REST Class

Class GSK.Rest1 Extends %CSP.REST
{
Parameter HandleCorsRequest = 1;
XData UrlMap [ XMLNamespace = "http://www.intersystems.com/urlmap" ]
{

<Routes>
<Route Url="/:name" Method="GET" Call="Test" Cors="true"/>

</Routes>
}

ClassMethod Test(name as %String) As %Status
{
w "Hello World "_name

Quit $$$OK
}
}
}

I am expecting result like " Hello World Gunwant"  from browser  ( localhost:57772/widgetsdirect/rest/Gunwant)

From Postman I am getting same result. But from browser service unavailable error I am getting.

Thanks,

Gunwant

It is most likely that you are trying to do a POST but by default the browser is invoking a GET. An alternative to POSTMAN is  Advanced REST Client for Chrome which can be invoked from within Chrome or you can download a Windows version as well. It is useful as you can save data to Google Drive and therefore make the data available to other devices that support chrome.

This is my REST Class

Class GSK.Rest1 Extends %CSP.REST
{
Parameter HandleCorsRequest = 1;
XData UrlMap [ XMLNamespace = "http://www.intersystems.com/urlmap" ]
{



}

ClassMethod Test(name as %String) As %Status
{
w "Hello World "_name

Quit $$$OK
}
}
}

I am expecting result like " Hello World Gunwant" from browser ( localhost:57772/widgetsdirect/rest/Gunwant)

From Postman I am getting same result. But from browser service unavailable error I am getting.

Thanks,

Gunwant