4 weeks ago
Hello all,
I am using ADF 7.x to create a custom component. However, I am encountering an issue when trying to use a REST API. Please find below the error message and my custom service:
3 weeks ago
Hi,
You are using standar angular http client module to implement the communication with alfresco repository so you need to add an Authentication Header to the call to obtain access to the resources.
Yo could try to use the AlfrescoApiService from ADF components to establish the comunication so the adf modules handle the authentication layer for you.
Example:
import { AlfrescoApiService } from '@alfresco/adf-content-services';
....
....
constructor(
....
private apiService: AlfrescoApiService,
....
){
....
....
public executeWebScript(
httpMethod: string,
scriptPath: string,
scriptArgs?: any,
contextRoot?: string,
servicePath?: string,
postBody?: any
😞 Promise<any> {
contextRoot = contextRoot || 'alfresco';
servicePath = servicePath || 'service';
postBody = postBody || null;
const allowedMethod: string[] = ['GET', 'POST', 'PUT', 'DELETE'];
if (!httpMethod || allowedMethod.indexOf(httpMethod) === -1) {
throw 'method allowed value GET, POST, PUT and DELETE';
}
if (!scriptPath) {
throw 'Missing param scriptPath in executeWebScript';
}
const contentTypes = ['application/json'];
const accepts = ['application/json', 'text/html'];
return this.apiService
.getInstance()
.contentClient.callApi(scriptPath, httpMethod, {}, scriptArgs, {}, {}, postBody, contentTypes, accepts, null, contextRoot + '/' + servicePath);
}
Regards
Explore our Alfresco products with the links below. Use labels to filter content by product module.