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.

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.

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)
    });
  }
}

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