REST API to update security level in a Jira issue
Platform Notice: Data Center - This article applies to Atlassian products on the Data Center platform.
Note that this knowledge base article was created for the Data Center version of the product. Data Center knowledge base articles for non-Data Center-specific features may also work for Server versions of the product, however they have not been tested. Support for Server* products ended on February 15th 2024. If you are running a Server product, you can visit the Atlassian Server end of support announcement to review your migration options.
*Except Fisheye and Crucible
Summary
In this article we will describe a scenario where security level field can be set using REST API.
This could be helpful in below mentioned scenarios:
- User want to update security level field of an issue.
Environment
Jira 8.x and later
Solution
With editIssue REST API, we can set security level in a ticket. Following is an example.
- Make sure to replace securitylevel (10000) with actual securitylevel ID
- KAN1-1 should be replaced with the actual issuekey
curl -v -u "username:password" -X PUT -H 'Content-Type: application/json' -d '{"fields":{"security":{"self": "http://localhost:8080/rest/api/2/securitylevel/10000","id": "10000","description": "It is internal to administrator group","name": "Internal"}}}' http://IP:HOST/rest/api/2/issue/KAN1-1
* Trying ::1:8080...
* Connected to localhost (::1) port 8080 (#0)
* Server auth using Basic with user 'cpandey'
> PUT /rest/api/2/issue/KAN1-1 HTTP/1.1
> Host: localhost:8080
> Authorization: Basic Y3BhbmRleTphdHJhdG9y
> User-Agent: curl/7.77.0
> Accept: */*
> Content-Type: application/json
> Content-Length: 39
>
* Mark bundle as not supporting multiuse
< HTTP/1.1 204
< X-AREQUESTID: 977x982x1
< Referrer-Policy: strict-origin-when-cross-origin
< X-XSS-Protection: 1; mode=block
< X-Content-Type-Options: nosniff
< X-Frame-Options: SAMEORIGIN
< Content-Security-Policy: sandbox
< Strict-Transport-Security: max-age=31536000
< Set-Cookie: JSESSIONID=516792C688AA227CB9D474260673E25C; Path=/; HttpOnly
< X-Seraph-LoginReason: OK
< Set-Cookie: atlassian.xsrf.token=BE8V-QK7K-JHAJ-01LP_9d609442b9ac33aadf1d1aa177e5e3f5fc8b58d5_lin; Path=/
< X-ASESSIONID: z7qfjp
< X-AUSERNAME: cpandey
< Cache-Control: no-cache, no-store, no-transform
< Content-Type: application/json;charset=UTF-8
< Date: Tue, 29 Mar 2022 10:47:19 GMT
<
* Connection #0 to host localhost left intact