Create
cancel
Showing results for 
Search instead for 
Did you mean: 
Sign up Log in

Need help sending a GET request in a User Macro

ELIS October 9, 2019

Hello,

I've been trying to setup a User Macro to send a GET request out to a website. Having a lot of trouble trying to figure this problem out, any help would be greatly appreciated.

Here is what I have:

I've imported and setup my httpRequest correctly. The problem I am currently having is setting up: HttpClientHttpResponse:

The constructor for this class is:

HttpClientHttpResponse(HttpRequest httpRequest, org.apache.commons.httpclient.HttpMethod method) 

I cannot seem to figure out how to initialize: org.apache.commons.httpclient.HttpMethod method

 

Here are a couple of attempts that I have tried:

#set($httpRequest = $content.class.forName("com.atlassian.confluence.util.http.HttpRequest").getConstructor().newInstance())
#set($httpMethod = $content.class.forName("org.apache.commons.httpclient.HttpMethod"))
#set($httpResponse = $content.class.forName("com.atlassian.confluence.util.http.httpclient.HttpClientHttpResponse"))

#set($response= $httpResponse.getConstructor($httpRequest.class, $httpMethod.class ).newInstance($httpRequest, $httpMethod))
#set($info= $response.getResponse()

 

#set($httpRequest = $content.class.forName("com.atlassian.confluence.util.http.HttpRequest").getConstructor().newInstance())
#set($httpMethod = $content.class.forName("org.apache.commons.httpclient.methods.GetMethod").getConstructor.NewInstance())
#set($httpResponse = $content.class.forName("com.atlassian.confluence.util.http.httpclient.HttpClientHttpResponse"))


#set($response= $httpResponse.getConstructor($httpRequest.class, $httpMethod.class ).newInstance($httpRequest, $httpMethod))
#set($info= $response.getResponse())

 

  • In this attempt, I tried to call the GetMethod Constructor

 

I've tried other variations but it all ends up failing with a cannot load user macro error. I can't use JavaScript and I am limited to setting this up in a User Macro.

 

Does anyone happen to have any suggestions on how to accomplish this, or if there are other ways to send a request to a website. I only need to call a website with 2 headers there is no need for content in the body.

 

I am new to confluence, I apologize if this is in the wrong forum section.

 

Thanks!

0 answers

Suggest an answer

Log in or Sign up to answer
TAGS
AUG Leaders

Atlassian Community Events