Expand my Community achievements bar.

Learn about Edge Delivery Services in upcoming GEM session
SOLVED

Can we use ECMA script to fetch an API endpoint?

Avatar

Level 4

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

Topics

Topics help categorize Community content and increase your ability to discover relevant content.

1 Accepted Solution

Avatar

Correct answer by
Community Advisor

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

View solution in original post

2 Replies

Avatar

Correct answer by
Community Advisor

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