I am trying to use Jira Automation to reorganize the ranking of two issues. I have successfully constructed the URL and body of the request, and validated that the request is being received. When I do, I get a 200 response (successful). However, the action in the PUT command is not happening and I can’t tell why.
Here’s the details with placeholders in [brackets]:
Web Request URL: https://[myspace].atlassian.net/jira/software/c/projects/[project]/rest/agile/1.0/issue/rank
Header:
content-type: application-JSON
HTTP method:
PUT
Web request body:
{
"issues": [
"[issue1]"
],
"rankAfterIssue": "[issue2]",
"rankCustomFieldId": "[custom field ID]"
}
When I make this request, nothing happens. I can’t tell if it’s because I’m not structuring the rankCustomFieldId value correctly or something else.
Welcome to the Atlassian Developer Community, @MikeMikaelian!
How were you able to come up with the current Web request URL? If by any chance you are planning to call Rank issues REST API, I believe the proper format of the URL would be https://[myspace].atlassian.net/rest/agile/1.0/issue/rank
. Also, you need to add an Authentication
header which contains the credentials to be used for calling the API.
For more information, this article on sending Jira Cloud REST APIs from Automation contains an easy-to-follow guide on how it can be set up.
Hope this helps.
Ian
EDIT:
Instead of Authentication
, this should be Authorization
.
Thank you for following up. Unfortunately, when I switch to the URL you provided it gives me a 401 error, despite the fact that I’ve added the Authentication header shown in the article you linked.
Here’s a screenshot of the configuration:
When I use the “Validate” button, here’s the response I get.
Response
500
Internal Server Error
Headers (8)
Server: squid
Mime-Version: 1.0
Date: Mon, 20 Nov 2023 06:00:14 GMT
Content-Type: text/html;charset=utf-8
Content-Length: 3449
X-Squid-Error: ERR_CANNOT_FORWARD 0
Vary: Accept-Language
Content-Language: en
Payload
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN" "http://www.w3.org/TR/html4/strict.dtd"> <html><head> <meta type="copyright" content="Copyright (C) 1996-2022 The Squid Software Foundation and contributors"> <meta http-equiv="Content-Type" content="text/html; charset=utf-8"> <title>ERROR: The requested URL could not be retrieved</title> <style type="text/css"><!-- /* * Copyright (C) 1996-2022 The Squid Software Foundation and contributors * * Squid software is distributed under GPLv2+ license and includes * contributions from numerous individuals and organizations. * Please see the COPYING and CONTRIBUTORS files for details. */ /* Stylesheet for Squid Error pages Adapted from design by Free CSS Templates http://www.freecsstemplates.org Released for free under a Creative Commons Attribution 2.5 License */ /* Page basics */ * { font-family: verdana, sans-serif; } html body { margin: 0; padding: 0; background: #efefef; font-size: 12px; color: #1e1e1e; } /* Page displayed title area */ #titles { margin-left: 15px; padding: 10px; padding-left: 100px; background: url('/squid-internal-static/icons/SN.png') no-repeat left; } /* initial title */ #titles h1 { color: #000000; } #titles h2 { color: #000000; } /* special event: FTP success page titles */ #titles ftpsuccess { background-color:#00ff00; width:100%; } /* Page displayed body content area */ #content { padding: 10px; background: #ffffff; } /* General text */ p { } /* error brief description */ #error p { } /* some data which may have caused the problem */ #data { } /* the error message received from the system or other software */ #sysmsg { } pre { } /* special event: FTP / Gopher directory listing */ #dirmsg { font-family: courier, monospace; color: black; font-size: 10pt; } #dirlisting { margin-left: 2%; margin-right: 2%; } #dirlisting tr.entry td.icon,td.filename,td.size,td.date { border-bottom: groove; } #dirlisting td.size { width: 50px; text-align: right; padding-right: 5px; } /* horizontal lines */ hr { margin: 0; } /* page displayed footer area */ #footer { font-size: 9px; padding-left: 10px; } body :lang(fa) { direction: rtl; font-size: 100%; font-family: Tahoma, Roya, sans-serif; float: right; } :lang(he) { direction: rtl; } --></style> </head><body id=ERR_CANNOT_FORWARD> <div id="titles"> <h1>ERROR</h1> <h2>The requested URL could not be retrieved</h2> </div> <hr> <div id="content"> <p>The following error was encountered while trying to retrieve the URL: <a href="https://[myspace].atlassian.com/*">https://[myspace].atlassian.com/*</a></p> <blockquote id="error"> <p><b>Unable to forward this request at this time.</b></p> </blockquote> <p>This request could not be forwarded to the origin server or to any parent caches.</p> <p>Some possible problems are:</p> <ul> <li id="network-down">An Internet connection needed to access this domains origin servers may be down.</li> <li id="no-peer">All configured parent caches may be currently unreachable.</li> <li id="permission-denied">The administrator may not allow this cache to make direct connections to origin servers.</li> </ul> <p>Your cache administrator is <a href="mailto:webmaster">webmaster</a>.</p> <br> </div> <hr> <div id="footer"> <p>Generated Mon, 20 Nov 2023 06:00:14 GMT by ip-10-125-126-49.net.atlassian.com (squid)</p> <!-- ERR_CANNOT_FORWARD --> </div> </body></html>
Request
PUT
https://[myspace].atlassian.com/rest/agile/1.0/issue/rank
Headers (3)
Authorization: **************************
Content-type: application/json
Accept: application/json; charset=UTF-8, */*;q=0.8
Payload
{
"issues": [
""
],
"rankAfterIssue": "",
"rankCustomFieldId": 10019
}
Hi @MikeMikaelian, based on your recent screenshot, you are using .com
instead of .net
in the URL, is this intended? If not, kindly change the URL and try again. Thanks.
Cheers,
Ian
https://[myspace].atlassian.net/rest/agile/1.0/issue/rank
When I change the URL to “.net” I get this error.
Send web request
Error publishing web request. Response HTTP status:
404
Error response HTTP body:
{"errorMessage": "Site temporarily unavailable"}
.com was actually in the documentation in the linked article.
Hi @MikeMikaelian,
Apologies for the confusion. Since in your original post, you used https://[myspace].atlassian.net
, my assumption is that your base URL is [instance].atlassian.net
. I also tried it in my Jira Cloud instance and so far it is working as expected
Going back to my previous reply, I incorrectly said Authentication
when I really meant Authorization
in the header, my mistake. Based on your screenshot, I believe you are using the correct header - be sure to base64 encode the email:apiToken
pair.
As for the HTTP 404
you are getting, I am not sure what is causing this and I was not able to replicate it.
Cheers,
Ian
1 Like
I’ve set up everything exactly the way you have, except I can’t use that URL; I get a 401 response when I do. When I use the original URL I posted back at the beginning, I get a 200 response (not a 204 response, as expected).
Well, not necessarily everything; besides the URL not being the same as the one you’ve been using, I can’t be certain the body of my call is correct. Since I’ve been getting 200 responses with my URL, is it possible that it’s the body that’s wrong? Replacing the variables with actual values, this would be an example of the body my script would create:
{
"rankAfterIssue": "MDN-131002",
"rankCustomFieldId": 10019,
"issues": [
"MDN-129390"
]
}
I was missing this detail. I was able to get it to work once I figured out how to do that encoding. Thanks, all set now!
2 Likes