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.
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:
request: string |
Request
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 APImethod?: HttpMethod
, GET, POST, PUT, DELETEheaders?: AllowedHeader
, content-type and accept headersqueryParams?: param: value
, map of querystring parametersrequestBody?: any
, body of the request