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
If you have to call Alfresco services is better to use the apiService:
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.
All the services in ADF are based on Alfresco REST v1 APIs. old webscripts should be called using ApiService as mentioned by @eugenio_romano
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.
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
Discussions, help and advice about the Alfresco Development Framework.
By using this site, you are agreeing to allow us to collect and use cookies as outlined in Alfresco’s Cookie Statement and Terms of Use (and you have a legitimate interest in Alfresco and our products, authorizing us to contact you in such methods). If you are not ok with these terms, please do not use this website.