Is there a way to use the JIRA REST api to update a value in the customfield

Alejandro Serrano July 17, 2017

{
    "customfield_15061":
    {
        "required":false,
        "schema":
        {
            "type":"string",
            "custom":"com.atlassian.jira.plugin.system.customfieldtypes:textfield",
            "customId":15061
        },
        "name":"Branch",
        "operations":["set"]
    }
}

 

So what I want to do is use the customId 15061 to update/delete/modify the string value since from whta I read the string value is attached to that ID

 

Also I want to do this using curl commands if possible so using POST or PUT along with passing the data with the --data flag.

 

Is this even possible or would I have to use something else to modify the value.

 

1 answer

1 accepted

0 votes
Answer accepted
Gaston Valente
Rising Star
Rising Star
Rising Stars are recognized for providing high-quality answers to other users. Rising Stars receive a certificate of achievement and are on the path to becoming Community Leaders.
July 17, 2017

You can try with this:

 


def issueKey = 'KEY-01'

def resultUpdate = put('/rest/api/2/issue/' + issueKey + '?overrideScreenSecurity=true')
.header('Content-Type', 'application/json')
.body([
fields:[
("customfield_15061"): "NEW VALUE"
]]).asString()

if (resultUpdate.status == 204)
return 'OK'
else
return "${resultUpdate.status}: ${resultUpdate}"
 
Alejandro Serrano July 17, 2017

curl -k -D- -u user:password -X PUT --data "{data here}" -H "Content-Type: application/json" mywebsiteBaseURL/rest/api/2/issue/currentIssue?overrideScreenSecurity=true

 

Would this be how the curl command would look like

and the data would look as follows:

 

{

    "fields":

    [{"customfield_15061":"NEW VALUE"}]

}

 

where "NEW VALUE" is the string i want to input?

Alejandro Serrano July 17, 2017

okay thanks for the code it was a good reference and
I managed to do the proper curl command which is as follows:

curl -k -D- -u user:password -X PUT --data "{"fields":{"customfield_15061":"Your New String Here"}}" -H "Content-Type: application/json" mywebsiteBaseURL/rest/api/2/issue/currentIssue?overrideScreenSecurity=true

 

Gaston Valente
Rising Star
Rising Star
Rising Stars are recognized for providing high-quality answers to other users. Rising Stars receive a certificate of achievement and are on the path to becoming Community Leaders.
July 18, 2017

great!

Suggest an answer

Log in or Sign up to answer