#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 Mariam Chaaban · Jun 7, 2023

Hello Team,

please can someone help me in the below.

I'm trying to call a Rest API below specification working in postman, and receiving perfectly the response: 

POST /PharmacyServices/api/Pharmacy/Upload?Key=aaaa&Username=bbb&Password=ccc HTTP/1.1
Host: abc:38440
Content-Length: 240
Content-Type: multipart/form-data; boundary=----WebKitFormBoundary7MA4YWxkTrZu0gW

------WebKitFormBoundary7MA4YWxkTrZu0gW
Content-Disposition: form-data; name="File"; filename="///xxxx/POC/CSV/20230607.csv"
Content-Type: text/csv

(data)
------WebKitFormBoundary7MA4YWxkTrZu0gW--

Here's what i'm trying to do in IRIS:
 

1
0 583
Article Cristiano Silva · May 27, 2023 6m read

How many times do we find ourselves rebuilding, copy-pasting, adapting, Business Operations that make calls to REST services, and only adapting one or another part of the final code. This is annoying a lot. To resolve this our inconvenience, I present to you Interopway REST, a set of classes (a micro framework) that allows us to just add Business Operation to Production and use it.

The project is hosted on github, https://github.com/cristianojs/interopway_rest, it is open and we are accepting collaborations.

Let's understand how this works.

Transport Objects

0
1 394
Article Heloisa Paiva · May 3, 2023 10m read

Programming and languages

Being a programmer nowadays is basically the geek version of being a polyglot. Of course, most of us here, in the InterSystems Community, “speak ObjectScript”. Howeever, I believe this wasn’t the first language for many people. For instance, I had never heard about it prior to getting the appropriate training at Innovatium.

8
3 969
Question Dmitrii Baranov · May 15, 2023

I have a production with a HLv2 HTTP Listener. For demo purposes, I need to send HL7 messages directly from a browser. Here is an example (React/typescript):

const message = "MSH...";
const args: RequestInit = {
      method: "POST",
      mode: "no-cors",
      body: message
 }

const response = await fetch(IRIS_SERVER_HL7_HTTP, args);
// await checkResponseAsync(response);
return await response.text();
1
0 387
Question Yone Moreno · May 16, 2023

Good morning:


Thank you very much for reading the doubt and above all thank you very much for answering.

Given the following use case:

If we have a Destination Service that through a HTTP GET by REST gives us a certain JSON response, where it should be noted that it is a list of objects where each object in the list does NOT have a key:

3
0 409
Question Menno Voerman · May 10, 2023

Hello everyone,

I am looking for a sort of REST interoperability adapter that can forward REST calls within HealthConnect. If necessary, we need to adjust the requests or responses.

For Fhir calls, we use the FHIR Interoperability Adapter. This works perfectly; a message comes in as HS.FHIRServer.Interop.Request, and a message HS.FHIRServer.Interop.Response goes out. I can make adjustments as needed to both the request and response. I am looking for the same functionality, but then for non-FHIR REST calls.

2
0 263
Article Eduard Lebedyuk · Apr 17, 2017 4m read

In this article I'll cover testing and debugging Caché web applications (mainly REST) with external tools. Second part covers Caché tools.

You wrote server-side code and want to test it from a client or already have a web application and it doesn't work. Here comes debugging. In this article I'll go from the easiest to use tools (browser) to the most comprehensive (packet analyzer), but first let's talk a little about most common errors and how they can be resolved.

2
5 3884
Question Dmitry Baranov · Apr 27, 2023

It is clear how to get the request header value with a specific name:

Class My.RestController Extends %CSP.REST
{

ClassMethod processRequest() As %Status
{
    #dim request as %CSP.Request 
    set request = %request
    set h = ##class(%REST.Impl).%GetHeader("...")
    ...    
    return $$$OK
}

But I can't figure out how to enumerate ALL the request headers (and also get all values).

7
0 902
Question Michael Davidovich · Apr 21, 2023

I have seen this post and appreciate that discussion: API RESTful Version | InterSystems Developer Community | Business Service

However our org requirement is for a caller to provide the API version in the HTTP request header.  I am finding the cleanest way to route to the correct class using the header version.  My classes are setup as

API.Service.v1

API.Service.v2

Of course only v1 exists now but when v2 goes live on future day, API.Service.v2 will extend API.Service.v1 so we only have to override the method that changes or add a new method if needed.  

2
0 360
Question Thembelani Mlalazi · Apr 17, 2023

I am using the %Net.HttpRequest class to download a file from the internet .using the following code. When a file is returned in the DOM I am able to read the file content and save it to the desired location but when my response is a download dialog nothing is returned in the HttpResponse. Am I doing something wrong here is where I have gotten to so far any help appreciated.

current code

1
0 483
Article Oliver Wilms · Apr 7, 2023 2m read

This week I was able to demo a proof of concept for our FMS interface on traffic cop architecture to my team. We are working on modernizing an Interoperability production running on mirrored Health Connect instances. We deploy IRIS workloads on Red Hat OpenShift Container Platform using InterSystems Kubernetes Operator (IKO). We can define any number of replicas for the compute stateful set where each compute pod runs our Interoperability production. We introduced Horizontal Pod Autoscaler (HPA) to scale up the number of compute pods based on memory or CPU utilization. But IKO scaled down

0
0 463
Question Shaun Munro · Mar 27, 2023

When using %JSONImport it seems to only report a single error, is there a way to report all the errors with out having to do multiple requests?  

{

    "errors": [

        {

            "code": 9406,

            "domain": "%ObjectErrors",

            "error": "ERROR #9406: Unexpected format for value of field, CurrencyCode, using Update mapping",

            "id": "JSONImportError",

            "params": [

                "CurrencyCode",

                "Update"

            ]

        }

    ],

    "summary": "ERROR #9406: Unexpected format for value of field, CurrencyCode, using Update mapping"

}

1
0 386
Question Elijah Cotterrell · Mar 6, 2023

I'm curious about how embedded Python is handled by %CSP classes, particularly in the case of defining REST endpoints on IRIS.
Here is a simple dispatch class for the endpoint /api/pythonapp on my local IRIS instance (2022.3):

Class Python.App.Dispatch Extends%CSP.REST
{

XData UrlMap [ XMLNamespace = "https://www.intersystems.com/urlmap" ]
{
<Routes>
    <Route Url="/test" Method="GET" Call="Hello" />
</Routes>
}

ClassMethod Hello() As%Status [ Language = python ]
{
    import iris

    print('Hello World!')
    return True
}

}
4
0 336
Question Sabit Issakhan · Oct 29, 2018

Hello Everyone!

Following the example below i can download file only txt format, in other format(pdf,xls,rar) i have errors(can't open file), 

So, how i will change code for download file in other format? 

Thanks! 

3
1 1484
Article Lorenzo Scalese · Feb 14, 2023 9m read

Hi Community,

I would like to take advantage of our topic on capture for Health Data Warehouses (on DC-FR) to show you how to quickly create HTTP SOAP and REST clients. IRIS, as well as applications available on Open Exchange offers solutions to generate them from a WSDL or a swagger specification.

SOAP client

Nothing could be easier than creating a SOAP client. All you need is the WSDL.A wizard is available from the IRIS Studio. It allows you to generate not only your classes for a web service client but also the “Business Services” and “Business Operations” if you want to consume them with the interoperability framework.

 

4
2 955
Article Daniel Aguilar · Feb 12, 2023 6m read

Hi! recently I have to apply api-key validation to a web app with a lot of endpoints and I'm going to tell you how I did it in a centralized way.

I'm going to explain you how we can apply in a generic way (or not) api-key validation to all the endpoints of our web app.

For this feature I take as a template the class Base.cls of this repository iris-rest-api-template

I modified a bit this class to be able to check api-key security. The idea is that in your features you copy this class in your projects and you extend it for your own implementations.

0
2 678
Article Lorenzo Scalese · Feb 7, 2023 9m read

Hi Community,

In the first part, we describe all packages, used libraries and REST services.

Now, I would like to add some details about converter and validator services.

By default, OpenAPI-Suite sends an HTTP request to converter.swagger.io if the specification version is less than 3.0 and another HTTP request to validator.swagger.io to simplify the structure of the specification document.  

Although the usage of online utilities is convenient, in some cases it could be better to have our own instance of the converter and validator.  For example, if OpenAPI-Suite is provided on a server in an organisation for ObjectScript developers, it may be preferable to avoid requests to external services (privacy, avoid request rate limits). 

Just run: 

docker run -d -p 8085:8080 --name swagger-converter swaggerapi/swagger-converter:latest
docker run -d -p 8086:8080 --name swagger-validator-v2 swaggerapi/swagger-validator-v2:latest
2
2 597
Article Evgeny Shvarov · Jun 24, 2020 3m read

Hi Developers!

Suppose you have a persistent class with data and you want to have a simple Angular UI for it to view the data and make CRUD operations.

Recently @Alberto Fuentes described how to build Angular UI for your InterSystems IRIS application using RESTForms2. 

In this article, I want to tell you how you can get a simple Angular UI to CRUD and view your InterSystems IRIS class data automatically in less than 5 minutes.

Let's go!

3
4 1368
Question Jaime Lerga · Feb 8, 2023

Recently i've been using Restforms2 to create a CRUD API for a project. But it lacks some advanced functionality that we need, so we have created a production with a REST WS which handles those advanced methods. That works great but there's a drawback, it does not have authentication. I would want to use the same authentication method as Restforms2 which is a basic auth using IRIS users and passwords. Searching for this, i have found a similar topic. It uses $SYSTEM.Security.Login(user, pass) in a similar manner to create a token. This works flawlessly if you use an account with all

4
0 1035
Article Daniel Aguilar · Feb 5, 2023 2m read

Hi Community!

I want to share with you mi first Open Exchange application.

It's a tool to made our developments easier. It's a micro service in a IRIS docker that help us in our new features giving us a way to add short links in our SMS, Email campaigns and for links of the different stores for our apps.

It's very easy to use it.

Simply clone this repo:

https://github.com/daniel-aguilar-garcia/cos-url-shortener.git

Open the folder in VSCode and start the docker.

 

After that you can create short link version of any link via api request. For example with Postman:

0
0 413
Question Chris Pursey · Jan 31, 2023

We have created a number of REST adapters that extend %CSP.REST and these have been working fine.  However, we are now facing a problem with a new one where very large XML documents are being posted.  This is the pattern we are following:

Set inMsg = %request.Content.Read()

Set tSC = ##class(Ens.Director).CreateBusinessService("Epro_ItkHttp",.tBusinessService)

Set tSC = tBusinessService.ProcessInput(inMsg, .tBusinessServiceOutput)

However, when the %request is particularly long, it is being truncated, and working with %XML.Reader then fails in the business service class.

4
0 613
Question Edoeard Kroetkov · Jan 23, 2023

I have code hier and trying to view diacrit character

Class Test.REST.Services Extends EnsLib.REST.Service
{

Parameter ADAPTER = "EnsLib.HTTP.InboundAdapter";

Parameter EnsServicePrefix = "^TEST";

XData UrlMap
{
<Routes>
<Route Url="/dio/:Resource" Method="GET"     Call="getDio" />
</Routes>
}

4
0 374
Article Yuri Marx · Jan 9, 2023 7m read

Applications that work with bill payments and receipts, as well as the delivery and inventory of items, generally require the use of barcodes or QR Codes. The latter is used in even broader scenarios since the QR Code can store more information than a simple bar code. Thus, it is important to have the ability to generate barcodes and QR Codes or read the data stored in them from an image or a PDF. This article will show you how to do this using Python and some of its free libraries.

Pyzbar library

1
2 1788
Question Colin Overton · Jan 19, 2023

Hi All,

I'm looking to write a 3rd party front end for BI cubes and have been directed towards the REST API here: https://docs.intersystems.com/iris20222/csp/docbook/DocBook.UI.Page.cls…

I've had quick test using postman and can use those fine, the issue I have is that there are some areas of metadata not exposed by the api that are essential to write a front end tool. I can list the cubes and measures using the /INFO/ paths, but that seems to be the limit of what is available.

6
0 379