Come for the products,
stay for the community

The Atlassian Community can help you and your team get more value out of Atlassian products and practices.

Atlassian Community about banner
4,365,548
Community Members
 
Community Events
168
Community Groups

400 - Bad Request upon issue edit with ScriptRunner

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

0 votes
Answer accepted

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

Suggest an answer

Log in or Sign up to answer
TAGS

Atlassian Community Events