Can we use ECMA script to fetch an API endpoint? | Community
Skip to main content
thatsmeadarsh
New Participant
April 3, 2024
Solved

Can we use ECMA script to fetch an API endpoint?

  • April 3, 2024
  • 1 reply
  • 594 views

I am trying to understand if there is any possible way to fetch an API endpoint using the ECMA script within workflow

This post is no longer active and is closed to new replies. Need help? Start a new post to ask your question.
Best answer by EstebanBustamante

Hi, 

Yes, you could do something like the code below, but I would recommend using a Java process instead and utilizing any HTTP client that would most likely be used across your implementation.

var get = new org.apache.commons.httpclient.methods.GetMethod("https://www.google.com"); var client = new org.apache.commons.httpclient.HttpClient(); var status = client.executeMethod(get); log.info("******** status " + status); get.releaseConnection();

 

Hope this helps.

1 reply

EstebanBustamante
EstebanBustamanteAccepted solution
New Participant
April 3, 2024

Hi, 

Yes, you could do something like the code below, but I would recommend using a Java process instead and utilizing any HTTP client that would most likely be used across your implementation.

var get = new org.apache.commons.httpclient.methods.GetMethod("https://www.google.com"); var client = new org.apache.commons.httpclient.HttpClient(); var status = client.executeMethod(get); log.info("******** status " + status); get.releaseConnection();

 

Hope this helps.

Esteban Bustamante
thatsmeadarsh
New Participant
April 4, 2024

Thanks Esteban this helps a lot.