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

It's not the same without you

Join the community to find out what other Atlassian users are discussing, debating and creating.

Atlassian Community Hero Image Collage

Need help sending a GET request in a User Macro

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
Community showcase
Published in Statuspage

New feature: Slack notifications for Statuspage

We're excited to announce the release of a long-requested feature on Statuspage. Now visitors to your status page can subscribe to get notified in Slack when you report an incident or maintenance. Th...

51 views 0 8
Read article

Community Events

Connect with like-minded Atlassian users at free events near you!

Find an event

Connect with like-minded Atlassian users at free events near you!

Unfortunately there are no Community Events near you at the moment.

Host an event

You're one step closer to meeting fellow Atlassian users at your local event. Learn more about Community Events

Events near you