Jira Automation Web Request to Confluence Cloud returning HTTP 302 REDIRECT

Brad Evans April 9, 2024

Attempting to use Jira automation to create a Confluence page and populate it's content when an issue is transitioned.

 

The "official" Confluence automation can only create pages, so I'm having to use it to create a page, and then use a Web Request PUT using the {{createdPage.id}} as the page identifier.

 

For testing the API's, I am creating the page and then calling DELETE as it requires no parameters, removing the possibility that the request body is the problem.

Automation:


automation-http-errors2.png


Audit log:

automation-http-errors.png

The Location header explicitly states that the request is being redirected to the login endpoint, but there is no way in the automation UI to tell the Web Request step to follow redirections.

How do I handle HTTP 302 in Jira automation?

 

P.S This has been asked before, but the user fixed it themselves and didn't explain their solution: https://community.atlassian.com/t5/Jira-Software-questions/Create-Confluence-Subpage-via-Web-Request-in-Jira-rule-HTTP-Code/qaq-p/2630582

5 answers

1 accepted

1 vote
Answer accepted
Brad Evans April 30, 2024

I managed to resolve this.

I wasn't supplying the Authorization header in the correct format:

Screenshot 2024-04-30 102209.png

 

Once I generated the header using this method in the documentation, everything worked. I did not need to add a port number in the URL.

 

Thanks for all your help.

Abdullah Said
Contributor
November 13, 2024

the irony of saying "This has been asked before, but the user fixed it themselves and didn't explain their solution: https://community.atlassian.com/t5/Jira-Software-questions/Create-Confluence-Subpage-via-Web-Request-in-Jira-rule-HTTP-Code/qaq-p/2630582" but you did it yourself with your own specific issue

Brad Evans November 13, 2024

I literally explained in the comment you are replying to how I resolved it..?

 

The screenshot of the docs guides you step by step to generate the Auth headers in the format Jira Automation needs them.

 

It might not have worked for you, but it did for me, thus resolved.

0 votes
taqeel508
I'm New Here
I'm New Here
Those new to the Atlassian Community have posted less than three times. Give them a warm welcome!
February 17, 2025

but how

 

0 votes
Abdullah Said
Contributor
November 13, 2024

all these answer are mostly badly configured self own API, meanwhile google apps script also had this issue with correct configuration

0 votes
Sara Shullaw April 24, 2024

@Robert Meeks did you ever find a solution? I'm trying to do the same thing.

Brad Evans April 25, 2024

I still can't get any calls using the Confluence API (v1 or V2) to work (https://{your-domain}:{port}/wiki/api/v2/pages/{id})

 

I can only get the Confluence URL to work with a GET request (https://{your-domain}/wiki/spaces/{space}/pages/{pageid}

I get redirects in every port and authorization Bearer configuration with this URL method.

 

Still waiting to hear from someone that has actually managed to do this in Jira Cloud and Confluence Cloud. Seems like something that should be fairly straightforward, no?

0 votes
Robert Meeks April 11, 2024

I had a similar issue, I just had to include the port number in the url.

Example:

https://your-domain.atlassian.net:{port}/rest/api/2/version/{id}

 

Brad Evans April 15, 2024

I imagine you need to specify the port if you are running Confluence server on your own infra (self-hosted)?

My problem is for a Confluence Cloud instance. Does it still apply, and if so which port number?

Robert Meeks April 16, 2024

Looking here it seems that if it's the default port it would be 8443 or 443.

Brad Evans April 16, 2024

443 returned the same 302, but 8443 returned 408 - timed out waiting for response. The DELETE operation was not carried out.

Robert Meeks April 16, 2024

I'm not sure if this would matter but which version of the confluence api are you using looking at your delete from the screen cap it looks a little different from the documentation.

 

Version 2:  https://{your-domain}:{port}/wiki/api/v2/pages/{id}

Link to the documentation:

https://developer.atlassian.com/cloud/confluence/rest/v2/api-group-page/#api-pages-id-delete

 

Version 1:  

Delete space: https://your-domain.atlassian.net:{port}/wiki/rest/api/space/{spaceKey}

Delete page: https://your-domain.atlassian.net:{port}/wiki/rest/api/content/{id}

 

Link to the documentation: https://developer.atlassian.com/cloud/confluence/rest/v1/api-group-content/#api-wiki-rest-api-content-id-delete

Brad Evans April 25, 2024

I can't get API v1 or v2 calls to work.

I get 404 NOT FOUND during the automation using the API, but pasting the exact same API page URL into the browser address bar gives the JSON of the Confluence page.

 

Automation must do some sort of parsing when you provide the non-API URL of the page in the web request HTTP URL field, as passing that values works with a GET.

As described before, anything other than a GET returns 302, redirecting to the login page.

This suggests an auth issue, but my bearer token is being hit (can see from the personal security settings "last accessed 9 minutes ago"), so I'm not sure what else I can provide to the automation.

Robert Meeks April 25, 2024

Hey @Brad Evans where did you get the url for the delete? Also just some more troubleshooting steps, can we try to use a curl command or nodeJS with both the GET and the DELETE method to see if there is some kind of pre-parsing as you've mentioned.

 

Hey @Sara Shullaw I got mine working by using the version 1 rest api for confluence, adding the port number, and following this process listed here .  My automation is slightly different, as I don't have a DELETE method, steps outlined below

 

  1. When a specific project version is released
  2. Get the contents of the confluence release page 
    1. https://{yourDomain}:443/wiki/rest/api/content/{pageID}?expand=body.storage,version
  3. Grab specific items via jira smart values
  4. Use a PUT method for the update to the page with the request structure being copied directly from the rest documentation and the body being changed via smart values.
    1.  https://{yourDomain}:443/wiki/rest/api/content/{pageID}

Suggest an answer

Log in or Sign up to answer
DEPLOYMENT TYPE
CLOUD
PRODUCT PLAN
STANDARD
PERMISSIONS LEVEL
Product Admin
TAGS
AUG Leaders

Atlassian Community Events