07-24-2019 05:45 AM
Hi,
I'm using the ADF-Framework and an Angular app with Typescript for my application.
I want to get nodes via the REST API and the request works flawlessly with Postman. However with Postman I have this extra authorization field I don't have in Typescript.
If I add a Header in my code for the request called Authorization with the value "usernameassword" I get a 502 response (The same thing happens if I add the header manually in Postman and don't use the fancy Authorization).
Is there any other way to authorize myself in the headers? I haven't configured an AuthGuard yet, I'm just working on Admin so I would like to set the value of username and password manually.
Regards
08-02-2019 05:41 AM
If you have to call Alfresco services is better to use the apiService:
09-21-2019 06:16 AM
But why can't I simply use the REST-API given by Alfresco?
I found out about my error beforehand and I simply forgot to encode my username and password. Now that I encoded everything and want to do it via Basic Authentication I still get a 401.
09-26-2019 11:49 PM
All the services in ADF are based on Alfresco REST v1 APIs. old webscripts should be called using ApiService as mentioned by @eugenio_romano
09-29-2019 11:49 PM
Hi kwiesinger,
I think that an example can make this clearer for you:
This is a service method from my code:
constructor(
private alfrescoApiService: AlfrescoApiService,
private errorHandlerService: ErrorHandlerService
) {
this.alfrescoApi = alfrescoApiService.getInstance();
}
getSites(preset: string😞 Promise<SitePaging> {
let options: object = {orderBy: 'title'};
if (preset) {
options = {where: `(preset=\'${preset}\')`, orderBy: 'title'};
}
return new WebscriptApi(this.alfrescoApi).executeWebScript(
'GET',
'sites',
options,
null,
'api/-default-/public/alfresco/versions/1',
null
).catch(
this.errorHandlerService.handlePromiseError<SitePaging>()
);
}
It basically executes the following REST call:
https://www.my-alfrescoserver.com/alfresco/api/-default-/public/alfresco/versions/1/sites?preset=%preset%&orderBy=title
Authentication and call handling is done by ADF.
10-01-2019 10:19 AM
Thank you for your reply, this was really helpfull and I will try it ASAP.
So it is not only Read-Only? (I read it somewhere in the Alfresco wiki).
Also due to the fact that I'm new to angular (learned it a few months ago): I can't simply use the HttpClient for this? I have to write/ use this Webscript API?
Is there a complete documentation in general about this Javascript API, I find github a bit confusing.
Regards
Explore our Alfresco products with the links below. Use labels to filter content by product module.