'How to consume Alfresco APIs from an angular application?

I have an angular application, and I want to interact with Alfresco community 7.1 via APIs from this List . how can I call these APIs?

Another question, I know that is possible to integrate ADF with angular applications, is there any tutorial or guide on how-to ?



Solution 1:[1]

you need to build a service that makes HTTP calls using HttpModule. Below is an example your service.

import { HttpClient } from '@angular/common/http';
import { Injectable } from '@angular/core';
import { Observable } from 'rxjs';

@Injectable({
  providedIn: 'root'
})
export class AlfrescoService  {
baseUrl="/alfresco/api/-default-/public/alfresco/versions/1";
constructor(private http: HttpClient) {}

getActionDefinitions(): Observable<any> {
  const specificRoute="/action-definitions?skipCount=0&maxItems=100";
  return this.http.get(baseUrl+specificRoute).pipe(
    map(res=>res)
  );
}

in your angular component you need to inject your service and subscrib to the function.

constructor(private alfrescoService  : AlfrescoService  ) {}

loadData(){
  this.alfrescoService.getActionDefinitions().subscribe({
    next:res=>{
      console.log(res)
    }
  })
}

Solution 2:[2]

If you want to interact with Alfresco API with an Angular Application :

I would suggest you generate an angular client from the OpenAPI Defintion of Alfresco webservices :

npm install @openapitools/openapi-generator-cli -g
openapi-generator-cli generate -g typescript-angular -i https://api-explorer.alfresco.com/api-explorer/definitions/alfresco-auth.yaml -o /<PATH_TO_OUTPUT>/

The Alfresco yaml are here :

Then, use the generated services to get a ticket from the authentication API, and then use the APIs you need.

If you want a link to some ADF documentation and in particular howtos

I would suggest you to look at the official documentation : https://www.alfresco.com/abn/adf/docs/tutorials/creating-your-first-adf-application/

Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source
Solution 1 Taha Zgued
Solution 2 Akah