How to Call Remote API from ADF

cancel
Showing results for 
Search instead for 
Did you mean: 
vidhipanchal
Established Member

How to Call Remote API from ADF

Jump to solution

Hello

I have configure my adf with alfresco by giving Ip address like xxx.xxx.x.x:8080 and i am also able to login.

Now I am trying to call custom webscript from adf using below api

import * as AlfrescoApi from 'alfresco-js-api';
alfrescoJsApi: any;
constructor(private apiService: AlfrescoApiService) {
   this.alfrescoJsApi = new AlfrescoApi({ provider: 'ALL' });
   this.alfrescoJsApi.core.webscriptApi.executeWebScript('GET', 'api/task-instances?authority=' +    this.authService.getEcmUsername())
}

but api is call localhost url like this

http://127.0.0.1:8080/alfresco/service/api/task-instances?authority=admin

insted of my configured ip.

How can i solve this?

Thanks

Vidhi

Regards,
Vidhi
1 Solution

Accepted Solutions
eugenio_romano
Alfresco Employee

Re: How to Call Remote API from ADF

Jump to solution

Hi the problem in your code is that you are instantiating a new alfrescoApi when you do :

   this.alfrescoJsApi = new AlfrescoApi({ provider: 'ALL' });

and this API new object is missing of configuration of the ecmHost that you should pass in the constructor.

In your case, you are already anyway injecting the ADF AlfrescoApiService in the constructor when you do 

constructor(private apiService: AlfrescoApiService) {
....
}
and you could use that instance of the js-api to do your job:

constructor(private apiService: AlfrescoApiService) {
this.apiService.getInstance().webScripti.executeWebScript('GET', 'api/task-instances?authority=' +   this.authService.getEcmUsername())
}

View solution in original post

7 Replies
eugenio_romano
Alfresco Employee

Re: How to Call Remote API from ADF

Jump to solution

Hi the problem in your code is that you are instantiating a new alfrescoApi when you do :

   this.alfrescoJsApi = new AlfrescoApi({ provider: 'ALL' });

and this API new object is missing of configuration of the ecmHost that you should pass in the constructor.

In your case, you are already anyway injecting the ADF AlfrescoApiService in the constructor when you do 

constructor(private apiService: AlfrescoApiService) {
....
}
and you could use that instance of the js-api to do your job:

constructor(private apiService: AlfrescoApiService) {
this.apiService.getInstance().webScripti.executeWebScript('GET', 'api/task-instances?authority=' +   this.authService.getEcmUsername())
}
vidhipanchal
Established Member

Re: How to Call Remote API from ADF

Jump to solution

Hi Eugenio Romano,

Thanks for reply.

What is the difference between "alfrescoJsApi.core.webscriptApi" and "apiService.getInstance().webScript"?

Thanks

Vidhi

Regards,
Vidhi
eugenio_romano
Alfresco Employee

Re: How to Call Remote API from ADF 

Jump to solution

The first is a new instance that you are going to declare that is nor initialized by ADF and you need to configure it and handle the lifecycle.

The second is an instance created by ADF when bootstrap the core. It gets the configuration from the app.config.json of the framework and you can consume it without care about the lifecycle of it

Upladder
Active Member II

Re: How to Call Remote API from ADF

Jump to solution

I tried

 

constructor(private apiService: AlfrescoApiService) {
 this.apiService.getInstance().webScripti.executeWebScript('GET', 'api/task-instances?authority=' +   this.authService.getEcmUsername())‍
}

The terminal said:

error TS2339: Property 'webScript' does not exist on type 'AlfrescoApi'.

KarekMedAM
Active Member II
Gustavo_DiasRT
Member II

Re: How to Call Remote API from ADF

Jump to solution

How can I make an alfresco request from ADF to a custom alfresco api, I tried this link but it's deprecated, can anyone help me?

rbaudu
Partner

Re: How to Call Remote API from ADF

Jump to solution

Hi,

do you get an answer to this ?

I have the same problem wirth adw wher we try to add a button with a call to a web script and nothing seems to work anymore.

We have no way to call the custom webscript we made on previous versions of Alfresco which were integrated in share !

Please, we need help.

Thanks

Best

Regis