Question Gunwant Kapade · 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

Comments

Jenna Makin · Sep 22, 2019

What kind of error do you get when you try from a browser.

From a browser URL the method is Get.   Is your service Method a Get?

Could also be licensing.

0
Gunwant Kapade  Sep 23, 2019 to Jenna Makin

Hi Kenneth,

I am getting service unavailable error.

Thanks,
Gunwant

0
Danny Wijnschenk · Sep 22, 2019

Hi Gunwant,

can you show us the postman screenshot, and your resthandler class.

It will be much easier for the community to solve your problem with this info, than having to guess,

Friendly Regards

0
Gunwant Kapade  Sep 23, 2019 to Danny Wijnschenk

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

0
Nigel Salm · Sep 22, 2019

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.

0
Gunwant Kapade · Sep 24, 2019

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

0
Jean Millette  Sep 24, 2019 to Gunwant Kapade

Hello Gunwant,

Can we assume that you've set up a Web Application named "/widgetsdirect/rest" via the Management Portal?

I've compiled your code and tested it and it works for me:

Best,

Jean

0
Gunwant Kapade  Sep 24, 2019 to Jean Millette

Hi Jean,

Yes, you are right. I have set up a Web Application named "/widgetsdirect/rest" via the Management Portal, just namespace name is different.

So while running from browser we need any additional settings ?

Thanks, Gunwant

0
Jenna Makin  Sep 24, 2019 to Gunwant Kapade

What does your full URL Map look like?

0