#REST API

10 Followers · 626 Posts

Representational state transfer (REST) is a software architectural style that defines a set of constraints to be used for creating Web services. Web services that conform to the REST architectural style, called RESTful Web services (RWS), provide interoperability between computer systems on the Internet. RESTful Web services allow the requesting systems to access and manipulate textual representations of Web resources by using a uniform and predefined set of stateless operations. Other kinds of Web services, such as SOAP Web services, expose their own arbitrary sets of operations.

Learn More.

Question Eduard Lebedyuk · Mar 28, 2017

Let's say I need to process these urls in one REST method:

http://host:port/REST/arg1/arg2/arg3
http://host:port/REST/arg1/arg2/
http://host:port/REST/arg1/arg2
http://host:port/REST/arg
http://host:port/REST/

Currently I need to define URL Map like this (assuming /REST web app):

XData UrlMap
{
<Routes>
   <Route Url="/:arg1" Method="GET" Call="GET"/>
   <Route Url="/:arg1/:arg2" Method="GET" Call="GET"/>
   <Route Url="/:arg1/:arg2/" Method="GET" Call="GET"/>
   <Route Url="/:arg1/:arg2/:arg3" Method="GET" Call="GET"/>
</Routes>
} 

Is there a way to get all these URLs in

5
0 491
Article Benjamin De Boe · Mar 20, 2017 4m read

This earlier article already announced the new iKnow REST APIs that are included in the 2017.1 release, but since then we've added extensive documentation for those APIs through the OpenAPI Specification (aka Swagger), which you'll find in the current 2017.1 release candidate. Without wanting to repeat much detail on how the APIs are organised, this article will show you how you can consult that elaborate documentation easily with Swagger-UI, an open source utility that reads OpenAPI specs and uses it to generate a very helpful GUI on top of your API.

1
0 1011
Question Tom Philippi · Mar 18, 2017

I have a Enslib.REST.operation which I want to use to send a JSON message. In Ensemble I am using the request message to the Business operation as an input for ObjectToJsonStream function so I can send it out (this is the way to go right?). However, I am now running into the fact that one of the attributes (template_name) contains an underscore and that I am not allowed to use the underscore to define the property in my ensemble RequestMessage:

Property template_name As %String;

What's the best way to resolve this?

1
0 439
Question Tom Philippi · Mar 15, 2017

I am relatively new to ensemble, but I am trying to build a REST operation using the enslib.Rest.Operation but I can't seem to get it to work at all. I am completely at loss here because the errors I am receiving are very unclear. I have tried a few different variants using PostURL and SendFormDataArray but I got errors on all variants. Suggestions are welcome.

The call I am trying to product is a simple ping message to the Mandrill APIat https://mandrillapp.com/API/1.0/users/ping.json (for more details see: https://mandrillapp.com/api/docs/users.JSON.html#method=ping).

The code for my business


2
0 1108
Question Chris Stewart · Jun 9, 2016

I've been building up a REST services API, consisting of a dozen or so classes referenced from a Dispatch class, which has route mappings for the first piece of the URI.  I'd like to have the Dispatch class be able to output all of the available Services, with some documentation.  Is there something like a %Library resource that I could use to pull this information from each of the classes?

Thanks

Chris

7
0 941
Question Manoj K · Mar 3, 2017

I created a simple CRUD operation using Rest Services in Cache.

Class EX.example Extends %CSP.REST{XData UrlMap{<Routes><Route Url="/insert/:loc/:ssn/:name" Method="GET" Call="hello"/><Route Url="/update/:key/:loc/:ssn/:name" Method="GET" Call="iam"/><Route Url="/delete/:key" Method="GET" Call="there"/><Route Url="/findid/:key" Method="GET" Call="now"/></Routes>}ClassMethod hello(name As %String, ssn As %String, loc As %String) As %Status{s mName=$zcvt(name,"U"),mKey=ssn,mLoc=locs ns=$namespaceznspace "USER"try{s obj=##class(Sample.Classes).%New()s o
5
0 531
Question Kurro Lopez · Mar 3, 2017

Hi all,

I have the following problem with a WebApi that I've developed in EBS.

I have a GET method that reads the parameters and puts into a message to process.

Class MyApp.BS.ServiceRestBase Extends (%CSP.REST, Ens.BusinessService)


XData UrlMap [ XMLNamespace = "http://www.intersystems.com/urlmap]
{
<Routes>
<Route Url="/login" Method="GET" Call="Login"/>
</Routes>
}
/// Login
ClassMethod Login() As %Status
{

// Get the parameters
set login = %request.Get("login")
set password = %request.Get("password")
set app = %request.Get("app")
....

}

The password is a value in Base64, if I call the WebApi with the fo

2
0 479
Question Manoj K · Feb 27, 2017

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

5
0 606
Question Andrei Luiz Nenevê · Feb 22, 2017

Hi everyone, I have and Zen Mojo application, it's all working but I have some doubts about what is recommended to use: There is some reports of employees, for example, and actually I'm using some plugins : "Excelent export" to generate Excel reports and "jspdf" to generate PDF reports in client side.

I have an REST service, that receives the request, process and returns JSON, after client side receive the response it's processed.

- This can be slow/bad in applications with large data?

- It's better/recommended to use ZenReports even with ZenMojo applications?

- Or Zen Mojo, like any other

2
0 437
Question Bahram Aziz · Feb 14, 2017

Hi,

I have Healthshare/Ensemble version 2015.2.1.

I created Business Operation in my ENSDEMO namespace that will connect to an external REST endpoint to send data to this external REST Service.

I also created an http service in Home>Healthshare>Service Registry, under the Service Type: http. I entered the REST endpoint Name, Host, SSL Configuration, and URL.

In my ENSDEMO production, the Business Operation is using EnsLib.HTTP.OutboundAdpater and my custom Rest business operation class. In the Basic Settings, for HTTP Server, I entered #NameofRegistryService. The HTTP Port and URL fields remain bl

1
0 704
Question Jenna Makin · Jan 31, 2017

Hi-

Im curious if there is any specific configuration that has to be done on an IIS web server to serve up RESTful web services.

I have a server that has IIS installed, with the CSP gateway.  a second server that has Cache installed on it.

I have configured a web application using the Cache System Management Portal for the web services that has a dispatch class pointing to my dispatch class.

I have created an application mapping in my CSP Gateway Management Portal on the web server such that url's with /webservices prefix are routed to my cache server.

There is a virtual directory created on the we

1
0 3831
Question Chris Stewart · Jan 5, 2017

I'm currently re-engineering an application from CSP pages directly accessing COS Methods, to an Angular/Material front end accessing a REST DAL.  Both the Angular front end and REST services are hosted from the same Caché instance and the same namespace, but the REST services have their own CSP application, with all calls being routed through a Dispatch class.  

I've come across an architecture issue recently, and am trying to assess the options I have.  At present, we encode a call to a class which takes in an OID and returns the Stream to the browser.  In the current application, this reques

5
0 639
Question Tani Frankel · Dec 8, 2016

Hi all (and specifically Eduard L. ;)

The Ensemble Workflow REST API provided here:

https://github.com/intersystems-ru/EnsembleWorkflow

(and mentioned before in this Community, also as the basis of the Angular UI, also available in the same Git) 

Has some very basic documentation as to how to work with the API (which also seems to be possibly a little out-dated as I think the /login URL is deprecated, for example).

Is there somewhere a more comprehensive documentation of this API?

Some of the API calls are quite simple and straightforward but others [specifically POST /tasks/:id] require in-depth kn

3
0 696
Question Bahram Aziz · Dec 9, 2016

Hi,

I am working with this Ensemble Business Operation, which extends the EnsLib.Rest.Operation.

http://docs.intersystems.com/latest/csp/docbook/DocBook.UI.Page.cls?KEY…

I built the OpenWeatherMap Rest Operation described in the article above.

I would like to access the weather.id weather.main, and weather.description. However, these objects are in a JSON Array.

How do you access these three objects in Objectscript.

In my,  Test.REST.WeatherOperation class, I added these three lines.

            set pResponse.WeatherId = tProxy.weather.id
            set pResponse.WeatherMain = tProxy.

3
0 1097
Question Bahram Aziz · Dec 7, 2016

Hi,

I was looking at the ENSDEMO namespace in our Ensemble server. In the class Demo.REST.DirectoryOperation, there is a line that uses the macro $$$URLENCODE. I would like to know exactly what does this macro $$$URLENCODE() do. Specifically what value does it. Unfortunately, I can't find anything about this macro in the Ensemble Documentation.

2
0 1619
Question George James · Oct 20, 2016

Evgeny

Thank you for your help yesterday at the Belfry.

When I try to subscribe to the RSS feeds using some news readers they do not accept them.

The W3C validator makes a lot of suggestions about what might be wrong, but my guess is that the feed title is blank.  Could this be fixed please?

W3C feed validator results for a group: http://validator.w3.org/feed/check.cgi?url=https%3A%2F%2Fcommunity.inte…

George

6
0 359
Question Lutz Vogt · Nov 23, 2016

We tested REST Services  as described for Caché DocServer example and for requests using http protocol it works without problems. However when we use the https protocol for the same REST Service it is not available. Our infrastructure is as follows: Apache with openssl, which works on the other hand well for CSP with https. If we switch on the web gateway http trace facility we could see the request of CSP pages by https://... but again a request of a REST Service by https:// will not result in a entry in the tracer. We hope that this description of the problem is understandable.

Any hint is

1
0 861
Question Chris Stewart · Nov 7, 2016

I'm working on a REST service which will include a binary stream as a request property. I'm currently encoding the stream as BASE64 and passing it as a string value, but I was wondering if there is anything in the Caché JSON support that may be a better fit for encoding this data? Thanks Chris

3
0 999
Article Istvan Hahn · Oct 21, 2016 4m read

A beginner’s guide to position Ensemble in regards to MicroServices Architecture (MSA). MSA is getting more visibility in the Enterprise Java world therefore it is vital to understand what is behind the buzz. I make a (humble) attempt to write my view and share with you.

Background

First of all I must confess. Early this summer our Czech colleague Daniel Kutac was asking me to collect some information about a health care product developed in Hungary. When I got the feedback from the related company, it turned out, that the product is a modular system, based on MicroServices Architecture (MSA). O

0
1 1035
Article Istvan Hahn · Oct 20, 2016 6m read

This is a beginner’s guide to the design of a “MicroService” implemented in Ensemble. “MicroService” is a popular phrase these days which has a broad interpretation. My interpretation is: “MicroService” is a “NoSQL Service”. A what? The answer is in the article.

We learnt what the difference is between SQL and NoSQL databases. For me the difference is nearly the same between a SOA Web Service and a “MicroService”. I am going to explain it through an example.

Please note, that although this is a beginner’s guide, I assume deep technology knowledge on data modelling, RESTful services and Ensemble.

0
0 1054
Article Istvan Hahn · Oct 12, 2016 12m read

Beginner’s guide to RESTful Application Program Interface (API) design and documentation. Through the example you will learn some common pattern for RESTful API.

Before you read

You need to know

  • How to create RESTful web service in Ensemble
  • How to consume RESTful web service in Ensemble
  • How to pass service parameters
  • How to return service result

What is a Service API?

What is an Application Programming Interface? Is it something materialized? Is it a single programming unit? What is an API for? From my point of view an API is something which is determined by the program code in an indirect way. But th

0
2 3264
Article Istvan Hahn · Oct 6, 2016 4m read

A beginner’s guide to Exception Handling in RESTful web services. The article gives an example how the various error conditions during processing a service request can be handled.

We expect our client – server communication working in a flawless operational condition, running error free software. But we are prepared to handle exceptions. Are we? So far in the examples of the previous sessions were not. We did not care about exceptions. The result? In any error incident it took ages to figure out what the problem is and more importantly how to fix it.

Remember, REST leans on HTTP. HTTP explic

1
0 1899
Article Istvan Hahn · Oct 5, 2016 13m read

This article gives a brief introduction how a RESTful service consumer and a RESTful service provider exchange data. It is a beginner’s guide. Data is transferred from a consumer to a provider as parameters of the service. Parameters are part of a service request. The result of the service action a response is returned from a provider to a consumer. Both the service request and response are standard HTTP messages. Since HTTP is a flexible standard regarding to the message contents, RESTful services also enjoy the versatility of data transfer methods.

During this session you can learn what optio

0
0 4659
Article Istvan Hahn · Sep 30, 2016 8m read

The article is a step by step guide for beginners to learn how to build a RESTful web service consumer (or client) in Ensemble. The provider can be any RESTful service, but the example is based on the service we made during the previous sessions.

It is more than obvious that many client development environment has programming libraries or containers to build a RESTful client. For example in the earlier sessions we used Java Script to access services. Ensemble as a container also offers client functionality. Let us have a quick list what Ensemble offers. Integrating an external resource is the

0
0 2843
Question Chris Bransden · Sep 29, 2016

Hi all,

We're creating a series of RESTful APIs that output data from a Cache database (made up of global storage that we've mapped to classes). I'm running into some problems with object-to-JSON conversions when relationships are involved. Eg:

ParentClass has children relationship to ChildClass

ChildClass has parent relationship to ParentClass

If you %WriteJSONFromObject on an instance of ChildClass, it will retrieve the instance of ChildClass you're asking for, and it will retrieve the ParentClass as a JSON sub object, via the parent relationship (this part is OK), AND it will retrieve EVERY oth

1
1 724
Article Istvan Hahn · Sep 27, 2016 5m read

Cross-origin Resource Sharing (CORS) is one of the basic security features built into browsers. CORS controls accessing resources from a HTML page in domains other than the original domain. It is particularly important for AJAX calls. Since RESTful services can be used as data provider to any AJAX call, you have to be able to control cross-origin access. By default services are not allowed to do CORS. You are going to learn how to enable it for Ensemble RESTful services.

The Resource Map class (the subclass of %CSP.REST) controls whether CORS is enabled. There are two approaches to do. One way

0
0 1607