#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 Kurro Lopez · Mar 15, 2024

Hi all,

For a requirement of the customer, we have a BS Rest api with a lot of methods, we need to get the IP of the caller, the method and what is the time that the API has taken to process.

I've found the event onPreDispatch where I can take the IP, ClassMethod, etc.. I'm using a global variable to save this information.

ClassMethod OnPreDispatch(pUrl As%String, pMethod As%String, ByRef pContinue As%Boolean) As%Status
{
	set^CallApi($CLASSNAME(),$JOB,"url") = pUrl
	set^CallApi($CLASSNAME(),$JOB,"method") = pMethod
	set^CallApi($CLASSNAME(),$JOB,"Start") = $HOROLOGset^Call
5
0 294
Question Ali Chaib · Mar 13, 2024

Dear,

I'm trying to configure a new interface that reads HL7, transform them into FHIR messages and then send POST or PUT or DELETE depending on HL7 doc type.

1-I added an HL7 TCP service that reads ADTs messages

2a-Send ADTs to a process to transform them into SDA  (using the following command:  do ##class(HS.Gateway.HL7.HL7ToSDA3).GetSDA(request,.con))

2b-Extract the patient MRN and add it to the AdditionalInfo property  (using the following request message class: HS.Message.XMLMessage)

3-Send the SDA message to the built in process: HS.FHIR.DTL.Util.HC.SDA3.FHIR.Process.

4-Send FHIR r

5
0 305
Question Yone Moreno · Mar 12, 2024

Hello,
First of all thanks for your time and help with this question.

We wonder how could we convert a String which represents an XML, to a class which extends from Ens.Response

Our context is a REST Operation, where we currently split the String with $PIECE and set each propertie as follows:

set codigo = $PIECE($PIECE(httpResponse,"<error><codigo>",2),"</codigo><descripcion>",1)
        set descripcion = $PIECE($PIECE(httpResponse,"<descripcion>",2),"</descripcion>",1)
        set codigoSERAM = $PIECE($PIECE(httpResponse,"</error><codigo>",2),"</codigo></resultado>",1)
        
5
0 224
Question Emil Odobasic · Mar 5, 2024

Hello everyone!
So, I am supposed to receive a REST-request into my production, and I need to send it, exactly as I received it, to another server.
I am struggling to find any good info on this, and have a hard time coming up with a good approach.
What would be the easiest way to do this?
- I have so far thought about possibly doing it with an EnsLib.REST.GenericService and then sending it with an EnsLib.REST.GenericOperation.
- I have also thought about manually creating a rest-service and somehow using %request and sending it directly if that would be possible.

I would be very thankful if I coul

4
0 338
Question Kurro Lopez · Feb 12, 2024

Hi all,

As you know, it is very complicated to debug a Business Service Rest API because the object is created when the applications receive a request, so we cannot have the JobId that we can use to debug.

https://docs.intersystems.com/iris20211/csp/docbook/DocBook.UI.Page.cls…

So, I'm trying to get the JobId when the class is being created, write a trace in OnInit() method and write the JobId in a log info

Method OnInit() As%Status
{
	$$$LOGINFO("JobId: "_$JOB)
	hang20breakQuit..OnInit()
}

Unfortunately, it seems to ignore this method because it doesn't show a

3
0 294
Announcement Emily Geary · Feb 29, 2024

Hi All,

On February 8, 2024, we asked for input from the IRIS community regarding exam topics for our InterSystems IRIS Developer Professional exam. We will close the window for providing feedback on the exam topics on Friday, March 8, 2024. If you would like to have your say in what topics are covered on the exam, this is your last chance!

How can I access the survey? You can access it here

  • Survey does not work well on mobile devices - you can access it, but it will involve a lot of scrolling
  • Survey can be resumable if you return to it on the same device in the same browser - answers sa
0
0 176
Question Armin Gayl · Feb 9, 2024

Hello,

I have a problem with a FHIR Interop scenario that the HTTP Header Value content-type between IRIS and client changes in case of an error (HTTP 422). If I set the status in the response to 200 OK as the last step in the service class, the return transmission works.

Within my operation class, the error code is taken from the source system and entered in the HS.FHIRServer.Interop.Response message. 

Within the CSP gateway I am also shown that the content type is 422 application/fhir+xml and is returned.

When I look at the packet in Wireshark, it is already text/html. 
A URL rewrite

3
0 427
Announcement Emily Geary · Feb 8, 2024

Hello Everyone,

The Certification Team of InterSystems Learning Services is developing an InterSystems IRIS Developer Professional certification exam, and we are reaching out to our community for feedback that will help us evaluate and establish the contents of this exam.

Note: This exam will replace the current InterSystems IRIS Core Solutions Developer Specialist exam when it is released. Please note from the target role description below that the focus of the new exam will be more on developer best practices and a lot less on the ObjectScript programming language.

How do I provide my inp

0
1 419
Question Emil Odobasic · Dec 20, 2023

Hello everyone!
I am wondering how I can retrieve multipart form-data from a request that is coming into my REST-service.
I am supposed to retrieve a string and a file. The file is being retrieved without issues, but the "testprofile" string is not being retrieved at all.
It just logs a an empty entry. 
The request that is sent to my REST-service has the Content-Type: multipart/form-data
Thanks beforehand for the help! :)

Down below is the code I use right now to retrieve the string and file from Form-data Rest HTTP-request to my service.

    set vProfile = %request.Get("testprofile")
    set vFi

5
0 939
Question Emil Odobasic · Jan 8, 2024

Hello everyone!
I am receiving a HTTP multipart/form-data request into my rest service.
How can I read the values for each Key in the form?
The key "Profile" is sent to my service as a String data type.
The code I have below does not seem to work, where I try to read the Key profile in the form.

I appreciate all the help I can get! :)

26
0 917
Article David Hockenbroch · Jan 4, 2024 22m read

So far, we have covered how to use ObjectScript to manage users, roles, resources, and applications. There are a few other classes in this package that work similarly to the ones mentioned above. However, these four classes are the ones everyone will have to use to manage their application security. Suppose you wanted to create your own Security management portal for this package. There would be some specific issues to think about for an API. Since the classes use similar methods, we can create fewer API endpoints using indirection. However, we should consider differences between those methods

2
3 471
Question Andy Stobirski · Jan 21, 2024

I've created a Rest Service as described here 

Configured the webapplication as described in the previous link, and now have a URL which I call in PostMan

http://VIR-HC-DEV-01.gmmh.nhs.uk:52773/api/mgmnt/v2/parisconnect/PCRest

Which returns the JSON spec as I would expect:

{
    "swagger": "2.0",
    "info": {
        "version": "1.0.0",
        "title": "Swagger Petstore",
        "description": "A sample API to demonstrate features in the swagger-2.0 specification",
        "termsOfService": "http://swagger.io/terms/",
        "contact": {
            "name": "Swagger API Team"
6
0 495
Question Andy Stobirski · Jan 20, 2024

Update - I answered my own question, so I'll just leave this here in case it can help someone.

Hi All

I'm following the tutorial Creating and Editing REST Services and have reached the step Using ^%REST to Create a Service and have encountered an error.

Here is grab of the terminal command:

PARISCONNECT>do ^%REST
 
REST Command Line Interface (CLI) helps you CREATE or DELETE a REST application.
Enter an application name or (L)ist all REST applications (L): PcConRest
REST application not found: PcConRest
Do you want to create a new REST application? Y or N (Y): Y
 
File path or abs
4
0 263
Question Sandeep K C · Jan 10, 2024

Hello Guys,

Our cache application uses REST web services and handles single API request perfectly with response (response status and related data). But sometimes user sends multiple requests to the same API simultaneously ( ie, without waiting for the first to respond ), where one request will succeed (not necessarily the first) and the others will fail. 
So, I need to handle the requests one by one after completing and sending the response for first request in the queue then process the next request and so on.

Is there any appropriate way of handling this problem? 

I found that, cache suppo

4
0 461
Question Ashok Kumar T · Dec 17, 2023

Hello Community,

Is there any way to avoid generating the built in validation inside the classmethod from the .disp class definition. I've added the resource with path parameter as integer in swagger 2.0 open API.  The class method(in my case getRandom is the class method) inside .disp handles the integer validation by default. Is there a way to avoid/remove by default.

default validations for Integer

If ($number(pmin,"I",-2147483648,2147483647)="") Do##class(%REST.Impl).%ReportRESTError(..#HTTP400BADREQUEST,$$$ERROR($$$RESTInvalid,"min",pmin)) QuitIf ($number(pmax,"I",-214748364
0
0 141
Question Emil Odobasic · Dec 14, 2023

Hello everyone!
I have to build a REST service that receives a POST HTTP-request, collect a file from that request in the Form data and then send it in another HTTP Post request through Form Data. However I can't really seem to send the file, and I do not know where it has gone wrong. All I am getting told is that no file is being received from my HTTP Post request. I am reaching the REST Service I am supposed to send the request to, but nothing is being sent.
I would be really thankful if someone could give some insight why nothing is being sent in my request. Thanks beforehand! :)

So, this is

6
0 995
Question Michael Wood · Dec 7, 2023

I have a message class define. But sometimes the RelatedItems fields is not returned. 

Parameter %JSONIGNOREINVALIDFIELD As BOOLEAN = 1;

Property RequestedTerm As AH.AHLIB.Custom.Symedical.Message.PostRelationResponse.termsRequested;

Property RelatedItems As list Of AH.AHLIB.Custom.Symedical.Message.PostRelationResponse.RelatedItems;
 

Respnse normally will return someting like this,

on ocassion the RelatedItems are not returned

have response context variable defined as the custom message type

How do I check in a BPL if there is no RelatedItems  in the response?
 

2
0 270
Question Denys Kondratiuk · Dec 7, 2023

I want to call the REST endpoint and return the list of objects. I`ve created the method but it displays an error: 
<METHOD DOES NOT EXIST>GetAllPersons+10^Lab3.RestClient.1 *Count,%ZEN.proxyObject

ClassMethod GetAllPersons() As%Status
{
    Set request = ##class(%Net.HttpRequest).%New()
    Set sc = request.Get("http://localhost:52773/csp/crud/persons") 
    Quit:$System.Status.IsError(sc) sc

    Set responseStream = ##class(%Stream.GlobalBinary).%New()
    Set response = request.HttpResponse.Data.Read()
    
    Write"Response from Server:", !, response, !

    Set pl = ##class



2
0 634
Question Denys Kondratiuk · Dec 5, 2023

I need to create a simple REST application.
I`ve created an app:

Also here is a dispatcher class:
 

Class Lab3.helloWorld Extends%CSP.REST
{

Parameter Authentication = 0;Parameter HandleCorsRequest = 0;
XData UrlMap [ XMLNamespace = "https://www.intersystems.com/urlmap" ]
{
<Routes>
    <Route Url="/hello" Method="GET" Call="Hello" />
</Routes>
}

ClassMethod Hello() As%Status
{
	Do##class(%REST.Impl).%SetContentType("application/json")
    If '##class(%REST.Impl).%CheckAccepts("application/json") Do##class(%REST.Impl).%ReportRESTError(..#HTTP406NOTACCEPTABLE,$$$ERROR($$$RES
2
0 617
Article Luis Angel Pérez Ramos · Dec 5, 2023 3m read

Welcome everybody!

In this short article I would like to present an example of use that surely many of you who work with IRIS as the backend for your web applications have faced on more than one occasion and it is how to send a file to your server from the frontend.

Generally the simplest way I have found to perform this task is to transform the file from the frontend to the Base64 format and make a POST call to our server attaching the Base64 obtained to a JSON message in which I indicate in a parameter the name of the file and in another the encoded data. Something similar to this:

{
   
2
0 736
Question Michael Wood · Nov 28, 2023

I getting the response back to my method fine,

but it is not returning to my BPL.

What am I missing to get the response back to the BPL?

// Execute REST Call
set tHttpResponse=##class(%Net.HttpResponse).%New()
set tSC = ..Adapter.SendFormDataArray(.tHttpResponse,"POST",tHttpRequest,"","",tURL)
set tStatusCode = tHttpResponse.StatusCode
$$$TRACE("Status Code: ["_tStatusCode_"]")
do ..logJSON(tHttpResponse.Data.Read(),"Post Relation Response")

// On HTTP 200 - OK
if tStatusCode = 200 {
     do tHttpResponse.Data.Rewind()
     do pResponse.%JSONImport(tHttpResponse.Data.Read())
     quit $$$OK

8
0 364
Question Brandon Butler · Nov 23, 2023

Hello all,

I have downloaded the latest community edition of IRIS and have stood up a vista system with File Manager, Taskman, the RPC Broker  etc up and running just fine on the latest FOIA release. I am trying to eventually connect a JS/React front end to a long-term mumps project of mine via the RPC Broker within my vista instance. I realize there is probably a much easier way to perform CRUD operations in my database via a web app without using the RPC Broker in a Vista instance, but I would like to eventually turn this project into a tool that my dev team could use, so need to do it this

7
0 393
Article Niels Genne · Nov 24, 2023 4m read

How can IRIS productions be deployed more quickly and with greater peace of mind?

The aim of interoperability productions is to enable you to connect systems in order to transform and route messages between them. To connect systems, you develop, configure, deploy and manage productions that integrate several software systems.

That’s what the InterSystems documentation on its reference website tells us, but what do you actually have to do to deploy a production ?

Productions can be composed to connect external systems to the IRIS Data Platform. To do this, it is necessary to create an enviro

LinkedIn profile

1
0 344
Question Yone Moreno · Nov 24, 2023

Hello,

First of all thanks for your time, thoughts, teaching and help:

We wonder how could we get the metrics from http://[Ip]:[Port]/api/monitor/metrics and use them in Kibana to chart statistics.

We would like to ask you how do you use the api monitor metrics, and as a second question, how would you suggest to utilize them in a third party software as Kibana to chart them.
 

We have thought to do the following:

1. Retrieve Metrics from Intersystems HealthShare API: Use a tool or script to make requests to the Intersystems HealthShare REST API and obtain the list of metrics. We could use



0
1 211
Question Michael Davidovich · Jul 27, 2022

After some trials, I am comfortably on my way developing spec first REST APIs using /api/mgmt/, OpenAPI 2.0, testing with Postman.

My question is related to scaling up.

Assume these things:

- Our software is CSP web app and it's web application is '/csp/application'

- I created a new REST enabled web app called '/csp/application/v1' and for my first API I created a spec that defines an endpoint /getTeapots so the endpoint is localhost/csp/application/v1/getTeapots

- Using the /api/mgmt/ endpoint, I loaded the spec into API.TeapotLibrary

- The dispatch class in '/csp/application/v1' thus

6
0 558
Question Yone Moreno · Oct 10, 2023

Hello,

First of all thanks for your time reading this post, and thanks for your help with your answers, thanks.

We have the following doubt: We need to create a REST Service in HealthShare, to process incoming calls with the following URL's format:

https://host:port/api/studies?patientId=11473564
 

To accomplish this task, we have previously read:

https://community.intersystems.com/post/advanced-url-mapping-rest

https://community.intersystems.com/post/how-do-i-process-querystring-pa…

https://community.intersystems.com/post/how-get-param-passed-get-r

9
0 545
Article Kari Vatjus-Anttila · Oct 20, 2023 11m read

I was attempting to find a solution to grant clients anonymous access to certain API endpoints while securing others within my REST API. However, when defining a Web Application, you can only secure the entire application and not specific parts of it.

I scoured the community for answers but didn't find any exact solutions, except one recommendation to create two separate web applications, one secured and the other unsecured. However, in my opinion, this approach involves too much work and creates unnecessary maintenance overhead. I prefer to develop my APIs spec-first and decide within the spe

7
1 875
Question Christine Hall · Oct 23, 2023

I am making a POST request to an API. In the case of an error, I don't know what parameters the response JSON will contain (they will change depending on the error). I am converting the response stream to an object but then I need a way to loop through all the properties and access their values. The following code is making the POST request, reading the response, and trying to add all the error messages to an array. But I can't iterate over the properties of the tProxy.errors object because it is a %ZEN.proxyObject. Is there a better way to do this?

Set tSC=..Adapter.Post(.tHttpResponse, , tP
2
0 321
Question Ashok Kumar T · Oct 22, 2023

Hello Community,

I've enabled the JWT Authentication in my web application. I invoked the /login page to get the JWT and it creates an entry in %SYS.TokenAuth table. Is there any time span for the entries will rid out from the table automatically or It's  a manual process? Where can I find the JWT signature private/public key 

settings screenshot

web application

0
0 238