How to run REST API through browser

Answers

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.

Comments

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.

Hi Kenneth,

I am getting service unavailable error.

Thanks,
Gunwant

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

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

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

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

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