Page 1 of 1

REST API GET/POST calls within Switch workflow via "Script Element"

Posted: Thu Nov 30, 2023 6:41 pm
by micahtds
Hello,

I am currently working on a project which requires calling an external System via REST API GET/POST calls. We currently have multiple SwitchScriptTool projects (using Visual Code) which utilize Axios HTTP request module. We are able to GET and POST within the Projects using Axios.

My question for the community:

How can we use the JS scripts produced by the Transpile function within a Switch Workflow (Script Element)? Has anyone successfully achieved this? If so, what modules were used?

Thanks in advance for any information provided.
Micah

Re: REST API GET/POST calls within Switch workflow via "Script Element"

Posted: Fri Dec 01, 2023 9:13 am
by foxpalace
Hi,
so really I don't know what you mean, this?
https://www.enfocus.com/en/learn/switch#scripting
I use in very much Scripts axios for API-Calls

Michael

Re: REST API GET/POST calls within Switch workflow via "Script Element"

Posted: Fri Dec 01, 2023 9:44 am
by freddyp
In a script element you point to an .sscript file, not to a JS file. Either that file is in a script folder with a size of 0 bytes. Or it is a packed script file in which case it has a certain size and it is a standalone package. You can pack the script folder using the SwitchScriptTool (run the tool without options to see the help, or read the documentation or watch the videos in the Learn section of our site).

The recommended practice is: use script folders during the development and use packed scripts in production.