06-28-2018 09:48 AM
Hey,
I don't understand how to use scriptArgs in [AlfrescoApiService].getInstance().webScript.executeWebScript in ADF.
I tried several ways, even using a regular string, but none of them worked.
I solved it for now by adding the args to tthe scriptPath and it works, but I wondered if someone could explain how the scriptArgs work.
this.apiService.getInstance().webScript.executeWebScript(
'GET',
`api/vmm/agendastructuur/workspace/SpacesStore/${result.id}?showAgendapunten=false`,
null,
null,
null,
null
).then(
(response: any) => {
const convertedResponse = this.objectToObjectArray(response);
// console.log(convertedResponse);
this.nodes = convertedResponse;
}
);
Thanks!
David.
06-29-2018 04:58 AM
Inside the project, there is an index.d.ts that should help your IDE to understand the types. Maybe your IDE is not configured in the riight way. Anyway, this the types: :
executeWebScript(httpMethod?: string, scriptPath?: string, scriptArgs?: any, contextRoot?: string, servicePat?: string, postBody?: string): Promise<{}>; |
It will compose an URL like that:
http(s)://(host):smileysad:port)/(contextPath)/(servicePath)/(scriptPath)?(scriptArgs)
scriptArgs is an object like that:
vat myParams = {
myUrlVar: 'value1',
myUrlVarTwo: 'value2',
};
So for example, if you use it:
this.alfrescoJsApi.core.webscriptApi.executeWebScript('GET', 'mytasks', myParams, 'share', 'differentServiceSlug');
It should invoke
http://127.0.01:8080/share/differentServiceSlug/mytasks?myUrlVar=value1&myUrlVarTwo=value2
06-28-2018 10:59 AM
Hi David maybe the official JS-API documentation can help you:
06-29-2018 02:27 AM
Hi Eugenio,
Thanks for answering.
The first thing that I have done was looking into the official documentation, I know where I should put the different parameters, but the exact format isn't defined there.
I already tried a flat string (in the example above it would be: "showAgendapunten=false") as third parameter, but I didn't get the desired results. I also tried an object, object Array, string Array as third parameter, it all didn't work.
David.
06-29-2018 04:58 AM
Inside the project, there is an index.d.ts that should help your IDE to understand the types. Maybe your IDE is not configured in the riight way. Anyway, this the types: :
executeWebScript(httpMethod?: string, scriptPath?: string, scriptArgs?: any, contextRoot?: string, servicePat?: string, postBody?: string): Promise<{}>; |
It will compose an URL like that:
http(s)://(host):smileysad:port)/(contextPath)/(servicePath)/(scriptPath)?(scriptArgs)
scriptArgs is an object like that:
vat myParams = {
myUrlVar: 'value1',
myUrlVarTwo: 'value2',
};
So for example, if you use it:
this.alfrescoJsApi.core.webscriptApi.executeWebScript('GET', 'mytasks', myParams, 'share', 'differentServiceSlug');
It should invoke
http://127.0.01:8080/share/differentServiceSlug/mytasks?myUrlVar=value1&myUrlVarTwo=value2
06-29-2018 05:37 AM
Thank you, this works.
My IDE (IntelliJ IDEA) is configured the right way to show hints, but I couldn't make out what the 'any' type stands for.
06-29-2018 09:12 AM
yep maybe we have to improve that type definition, good point thanks
Explore our Alfresco products with the links below. Use labels to filter content by product module.