Hey everyone.
I am attempting to access the entity properties of an issue via a HTTP request. I can get an equivalent curl request to work, however when I attempt to execute this in ScriptRunner it fails.
Here is the script I am trying
import java.net.HttpURLConnection
import java.net.URL
def authStr = Base64.getEncoder().encodeToString("admin:admin".getBytes())
def baseURL = "http://localhost:2990/jira/rest/api/2/issue/JSD-11/properties/"
def url = new URL(baseURL);
def connection = url.openConnection() as HttpURLConnection;
connection.requestMethod = "GET"
connection.setRequestProperty("Content-Type", "application/json")
connection.setRequestProperty("Authenticate", "Basic " + authStr)
def headers = connection.headerFields
//connection.outputStream.withWriter("UTF-8") { new StreamingJsonBuilder(it, body_req) }
connection.connect();
I am getting the following error message:
{"errorMessages":["You do not have permission to browse issues in this project."],"errors":{}}This is what the logs say:
2019-08-07 13:57:09,347 WARN [httpclient.HttpMethodDirector]: Unable to respond to any of these challenges: {oauth=OAuth realm="http%3A%2F%2Flocalhost%3A2990%2Fjira"}
2019-08-07 13:57:09,348 WARN [httpclient.HttpMethodBase]: Going to buffer response body of large or unknown size. Using getResponseBodyAsStream instead is recommended.
As I said, I can get this work using a simple Curl request, but I cannot seem to get the authorization working in ScriptRunner.
The curl request I use is:
curl -u admin:admin http://localhost:2990/jira/rest/api/2/issue/JSD-11/properties/
I have tried other methods to make the HTTP call such as using org.apache.commons.httpclient.HttpClient but that yielded similar results.
The version of Jira I am using is pretty much a clean install - with little configuration changes made except for installing ScriptRunner.