#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.

Job sandeep sunny · May 26, 2022

Client: Northwell Health

Role: Senior Developer

Location: Remote

Duration: 6+ Months

Description:

Team Overview:

The FHIR Platform team is tasked with providing the core infrastructure in providing access to Northwell HIE patient data complying with HL7 FHIR and USCDI standards.

Position Summary:

The primary purpose of this role is to provide technical design, coding, testing and documentation for multiple components in the FHIR solution.

Responsibilities:

• Develop end-to-end solutions, participate in code reviews, unit test and deploy.

• Documentation of technical designs and functionality

0
0 447
Question Thomas Vessiere · May 5, 2022

Hello. 

I'm trying to POST a JSON on an URL. 

But the body request arrive empty on the web service : 

[DEBUG] # 2022-05-05 15:04:32,966 # scopes founds : api
[DEBUG] # 2022-05-05 15:04:32,971 # PatientController:PostSignaletic object null

Here is the code, i tried a TONS of ways to do it but i'm still in trouble ... 

Method SendSignaletique(Token As %String)
{
    //set UrlPats = "https://app.depistagesurdite.be/externaldemo"
    
    /*set internalID = "123456789"
      set lastName = "Test"
      set firstName = "CHRV"
      set dateOfBirth = "2022-05-04"
      set gender = "1"
14
0 580
Question Abraham Wasswa · May 1, 2022

Given I have a property 

Class All.AllBooks Extends %Library.Persistent
{

Property ID As %Integer;

Property Title As User.Book;

}

 

In the class method

ClassMethod GetABookById(id As %Integer) As %Status
{

SET MyBooks = ##class(All.Allbooks).%OpenId(id)

SET obj = {

     "ID" : (MyBooks.%Id())

     "Title" : (MyBooks.Title)

}

WRITE obj.%ToJSON()

Quit 1
}

 

How do Access the foreign key in JSON() data

7
0 680
Article Eduard Lebedyuk · Jun 19, 2020 2m read

Recently I needed to generate a Swagger spec from persistent and serial classes, so I'm publishing my code (it's not complete - you still need to hash out the application specifics, but it's a start). It's available here.

Let's say you have these classes:

 

Classes

14
3 1972
InterSystems Official Stefan Wittmann · Feb 16, 2021

The GA release is now published for the 1.5 version of the InterSystems API Manager (IAM).

 

The container for IAM, including all relevant artifacts to upgrade from earlier versions of IAM can be downloaded from the WRC Software Distribution site in the Components area.

 

The build number for this release is IAM 1.5.0.9-4.

 

InterSystems API Manager 1.5 makes it easier to manage your API traffic, integrate with your environment and onboard users of your APIs. It has many new capabilities, including:

 

  • Improved User Experience
  • Introducing new Developer Portal tools
  • Support for Kafka connectivity
6
0 702
Question Vivek Nayak · Mar 8, 2022

Hi Team,

I got a 404 status code(fhirResponse.Status) in the below code while inserting patient resources. Other resources data are successfully inserted.

Class HS.FHIRServer.Interop.Operation Extends (Ens.BusinessOperation, HS.HC.Util.Trace.Helper)
{Parameter SETTINGS As %String;XData MessageMap
{
<MapItems>
<MapItem MessageType="HS.FHIRServer.Interop.Request">
<Method>DispatchRequest</Method>
</MapItem>
</MapItems>
}Method DispatchRequest(pInteropRequest As HS.FHIRServer.Interop.Request, Output pInteropResponse As HS.FHIRServer.Interop.Response) As %Status
{
Set tSC = $$$OKTry {
// Get the FHIR

3
0 366
Question Harshdeep Acharya · Feb 28, 2022

If I add the same patient data with a different unique ID then it inserts as new data using a POST request.
So, In the FHIR server How can I prevent this kind of thing by using POST requests?
Note:- I don't want to use a PUT request for the same. The main thing is I want to get a unique patient record.
Que:- Is there any way to check data duplication on each FHIR resource?

Thanks & Regards,

Harshdeep Acharya

1
0 541
Article Yuri Marx · Dec 3, 2021 7m read

Creating REST API using InterSystems ObjectScript is very easy, but some recipes can help you into this process:

1) To create your REST API extends %CSP.REST and Go to System Administration > Security > Applications > Web Applications > Click the button Create New Web Application and set the Name, REST Dispatch Class with your package and classname and choose the Allowed Authetication Methods. See this example:

 

Edit Web Application

2) Configure your REST API using ZPM configuration. To do this follow this sample (watch the tag <CSPApplication>):

 

ZPM Code to Create REST API

<?xml
2
7 1915
Article Yuri Marx · Feb 2, 2021 4m read

Spring Boot is the most used Java framework to create REST API and microservices. It can be used to deploy web or executable web or desktop self-contained apps, where the application and another dependencies are packaged toghether. Springboot allows you do to a lot of functions, see:

Note: to learn about SpringBoot see official site - https://spring.io/quickstart

To create an web api application, with one or more microservices can you use Spring IDE for Eclipse or VSCode and use a wizard to config the technologies above that will be used into your app, see:

You select the technologies and create

9
1 2905
Article Yuri Marx · Feb 2, 2022 1m read

If your REST API need return a file to the client download, this is the source code that you could write (P.S.: extracted from the question https://community.intersystems.com/post/download-file-rest and its responses):

Set%response.ContentType="image/jpeg"
Do%response.SetHeader("Content-Disposition","attachment;filename=""test.jpg""")
Set%response.NoCharSetConvert=1
Set%response.Headers("Access-Control-Allow-Origin")="*"

 

Setstream=##class(%Stream.FileBinary).%New()
Setsc=stream.LinkToFile("/opt/irisbuild/output/test.jpg")
Dostream.OutputToDevice()

 

SettSC=$$$OK
0
0 934
Article Yuri Marx · Jan 30, 2022 2m read

If you need create a upload REST API with IRIS is very simple. Do these procedures:

From Postman client you send a file

P.S.: It is a multipart form with a file type using "file" in the name. The request type is form/multipart. See the http request:

POST /image-analyzer/postFile HTTP/1.1
Host: localhost:52773
Content-Length: 213
Content-Type: multipart/form-data; boundary=----WebKitFormBoundary7MA4YWxkTrZu0gW

----WebKitFormBoundary7MA4YWxkTrZu0gW
Content-Disposition: form-data; name="file"; filename="/C:/Users/yurim/OneDrive/Imagens/salesschema.png"
Content-Type: image/png

(data)
0
3 974
Question Vivian Lee · Dec 20, 2021

I'm trying to send an HTTP POST request with form-data from an Angular app to a Cache backend, but my request fails with a 406 Not Acceptable error.

httpRequestHeaders = new HttpHeaders({
  Authorization: 'Bearer ' + sessionStorage.getItem('access_token'),
  Accept: ''
}); 

uploadFile(file: File) {
  const formData: FormData = new FormData();
  formData.append("file", file);
  const req = new HttpRequest("POST", this.postURL, formData, {
    reportProgress: true,
    responseType: "json",
    headers: this.httpRequestHeaders,
  });
  return this.http.request(req);
}

Though I'm

2
0 16227
Article Chris Stewart · Apr 18, 2017 3m read

or "So you just got yelled at by your boss, for sending him an unformatted Hello World webpage"

Our previous lesson ended with us serving a Message value obtained from a Caché REST service to the client, using Angular as a runtime.  While there is a lot of moving parts involved in this process, the page is not especially exciting at the moment.  Before we can start adding new features, we should take a step back and review our tools.


This tutorial is using the JSON functionality built into 2016.2+ versions of Caché.

1
1 2695
Article Yuri Marx · Nov 25, 2021 3m read

The XData (https://docs.intersystems.com/irislatest/csp/docbook/DocBook.UI.Page.cls?KEY=GOBJ_XDATA) is a powerful feature to set documentation and metadata information for classes and methods. The %CSP.REST class uses XDATA to mapping REST calls (https://docs.intersystems.com/irislatest/csp/docbook/DocBook.UI.Page.cls?KEY=GREST_csprest), so in this article you will see how to use XData into your apps as code, not only as documentation.

When you write XData comments/definitions, the IRIS store it into %Dictionary.ClassDefinition (for classes) %Dictionary.MethodDefinition (for methods).

4
1 650
Article Jose-Tomas Salvador · Dec 30, 2021 1m read

For those that, at some point, need to test what means that of ECP for horizontal escalability (computing power and/or users and processes concurrency), but they're lazy o have no much time to build the environment, configure the server nodes, etc..., I've just published in Open Exchange the app/sample OPNEx-ECP Deployment .

0
0 343
Article José Pereira · Dec 22, 2021 5m read

What about having your IRIS REST APIs scanned every push you did and being reported on possible vulnerabilities? This is what I am going to show you in this article.

Recently, we had the Security Contest with amazing applications and examples showing how to improve security on your IRIS solutions. One of such examples was the zap-api-scan-sample, made by me and my colleague Henrique Dias. Our application shows how to use the OWASP ZAP API scanner to perform security tests on your REST APIs OpenAPI definitions generated by IRIS.

Now, we did an improvement on such example, using ZAP GitHub Action

0
0 1615
Question James Westley-Farrell · Dec 7, 2021

I've never had a problem changing the content-type on a response using either %CSP.Page or %CSP.REST until now. No matter where I put the line to set the content-type to "application/json", it stubbornly emits a content-type of "text/html".

In OnPreHTTP: (I tried one at a time)
either
    do %response.SetHeader("content-type", "application/json") // didn't work
or

    set %response.ContentType = "text/plain" // didn't work

The same lines in OnProcessInput() didn't change the output content-type, either.

The class signature is 
Class HS.Local.VA.HS.DocRepo.Prefetch.Service.RESTService Extends (Ens.Busi

4
0 1132
Question prashanth ponugoti · Dec 2, 2021

I am totally struck and last 3 days I am not able to progress much. Here I need to call POST method in REST endpoint in Business Operation.

Please find the code below, which is working fine in IRIS 2020.1 but not in cache 2017.

$$$LOGINFO("InvokeTokenAPI...")
try
{
Set httpRequest= ##class(%Net.HttpRequest).%New()
Set httpRequest.Server = ..Adapter.HTTPServer
Set httpRequest.Location = ..Adapter.URL
Set httpRequest.SSLConfiguration = ..Adapter.SSLConfigSet httpRequest.Https = $$$YES
Set httpRequest.ContentType = "application/x-www-form-urlencoded"do httpRequest.InsertFormData("grant_type", pRequest.

8
1 306
Question Juuso Lepistö · Nov 5, 2021

I'm trying to send a POST request to my REST API and I'm getting this error and most likely due the lack of experience, I have no idea how to fix this issue:  

"error": "ERROR #9406: Unexpected format for value of field, AlertText, using class base mapping",

            "id": "JSONImportError",

            "params": [

                "AlertText",

                "class base"

            ]

Am I missing something from my string definition?

Defined below as:

Class User.RESTComponents Extends (%Persistent, %JSON.Adaptor, %Populate)

{

Property AlertText As %String;

Here is my POST -method:

/// Creates a new

4
0 589