ADF Call Post webscript

Showing results for 
Search instead for 
Did you mean: 
Senior Member II

ADF Call Post webscript

I am trying to get datalist value in my adf application and i can use GETmethod properly but at one place i need to call POST method so how can i call post method with body?

Below way I am using GET method.
this.alfrescoJsApi.core.webscriptApi.executeWebScript('GET', 'slingshot/datalists/data/node/workspace/SpacesStore/ce744915-6130-40b8-9c57-6b7c442f656f')
.then(function (data) {
console.log('Data' , data);
}, function (error) {
console.log('Error' + error);
Thanks & Regards,
2 Replies
Alfresco Employee

Re: ADF Call Post webscript

Hi as from documentation that you can find in the alfresco-js-api repository:

GitHub - Alfresco/alfresco-js-api: This project provides a JavaScript client API into the Alfresco R... 

you need to change the input parameters.

executeWebScript(httpMethod, scriptPath, scriptArgs, contextRoot, servicePath, postBody)

The first httpMethod as to be 'POST'

The last parameter the postBody.

So in your case for example:

this.alfrescoJsApi.core.webscriptApi.executeWebScript('POST', 'slingshot/datalists/data/node/workspace/SpacesStore/ce744915-6130-40b8-9c57-6b7c442f656f',null, null, nul, postBody )

Active Member II

Re: ADF Call Post webscript

Also you can import AlfrescoApiService like follows
import { AlfrescoApiService } from '@alfresco/adf-core';

declare it in constructor like follows
constructor(private apiService: AlfrescoApiService)

and can call any post method as follows

(response: any) => {}