400 - Bad Request upon issue edit with ScriptRunner

a.borger
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!
December 5, 2019

Currently facing the following problem; I am trying to update an issue through ScriptRunner with the following script:

def response2 = put('/rest/api/3/issue/' + issueID)
.queryString("overrideScreenSecurity", Boolean.TRUE)
.queryString("overrideEditableFlag", Boolean.TRUE)
.header('Content-Type', 'application/json')
.header('Authorization', <token>)
.body([
fields: [
summary: [
set: "<string>"
]
]
])
.asString()

 It returns a 400 - Bad Request error (HTML formatted with no additional details). However, the exact same request in Postman results in no errors and the content is updated accordingly (Postman code below).

 

HttpResponse<String> response = Unirest.put("<baseurl>/rest/api/3/issue/ISD-1")
.header("content-type", "application/json")
.header("authorization", <token>)
.header("cache-control", "no-cache")
.header("postman-token", "fa61e5b1-df1e-5855-eafb-101ce7cbf7b4")
.body("{\"update\": {\"summary\": [{\"set\": \"<string>\"}], \"customfield_10038\": [{\"set\": \"<string>\"}]}}")
.asString();

 

1 answer

1 accepted

Suggest an answer

Log in or Sign up to answer
0 votes
Answer accepted
Kristian Walker _Adaptavist_
Community Leader
Community Leader
Community Leaders are connectors, ambassadors, and mentors. On the online community, they serve as thought leaders, product experts, and moderators.
December 6, 2019

Hi, a.borger,

Thank you for your question.

I can confirm that the reason that you are getting the error above is due to the fact that the structure of your rest call is not valid for ScriptRunner for Jira Cloud.

I can confirm that we have an example script which shows how to Update an Issue inside of the documentation page located here.

You will be able to take this example this script and run this on the Script Console in order to test updating an issue and to figure out the correct syntax which you require.

If this response has answered your question can you please mark it as accepted so that other users can see it is correct when searching for similar answers.

Regards,

Kristian

TAGS
AUG Leaders

Atlassian Community Events