REST Service

The Rest Service (CloudAppRestService) provides the ability to call REST APIs in Alma. APIs called from the Rest Service are run in the context of the logged-in user. The user must have permissions to perform the action implemented by the API, and any history actions are logged under the user’s identity. If the Cloud App attempts to call an API which performs an action for which the logged-in user does not have the proper role, Alma will return a 401 Unauthorized to the Cloud App.

APIs called from a Cloud App are not counted towards an institution’s governance threshold. API calls from Cloud Apps are limited to 10 simultaneous requests and 25 requests in 5 seconds. Cloud Apps are intended to provide online rather than batch processing, for which jobs should be used.

The following methods is available:

call

This method is used to call REST APIs in Alma. This method will automatically queue requests above the threshold so it is safe to call in parallel.

Interface

call(request: string | Request): Observable<any>

Parameters:

Examples

Basic GET Request:

import { CloudAppRestService } from '@exlibris/exl-cloudapp-angular-lib';

export class MainComponent implements OnInit {

  constructor( private restService: CloudAppRestService ) { }

  ngOnInit() {
    this.restService.call('/users').subscribe(
      users => console.log('users', users);
    );
  }
}

POST Request:

import { CloudAppRestService, Request, HttpMethod } from '@exlibris/exl-cloudapp-angular-lib';

export class MainComponent implements OnInit {

  constructor( private restService: CloudAppRestService ) { }

  ngOnInit() {
    let user = { first_name: "John", last_name: "Smith", account_type: { value: "INTERNAL" } };
    let : Request = {
      url: '/users',
      method: HttpMethod.POST,
      requestBody: user
    };
    this.restService.call(request).subscribe(
      user => console.log('User created', user);
    );
  }
}

Error Handling

import { CloudAppRestService } from '@exlibris/exl-cloudapp-angular-lib';

export class MainComponent implements OnInit {

  constructor( private restService: CloudAppRestService ) { }

  ngOnInit() {
    this.restService.call('/users/NONEXISTENT').subscribe({
      next: user => console.log('User created', user),
      error: e => console.error('Error', e.message)
    });
  }
}

Esploro & Rapido

In order to all Esploro & Rapido APIs, add the full path of the APIs. For example:

  this.restService.call('/esploro/v1/assets/test').subscribe(     );
  this.restService.call('/rapido/v1/resources/test').subscribe(     );

Interfaces

Request

Properties:

  • url: string, path of the requested API
  • method?: HttpMethod, GET, POST, PUT, DELETE
  • headers?: AllowedHeader, content-type and accept headers
  • queryParams?: param: value, map of querystring parameters
  • requestBody?: any, body of the request