So, I've been struggling to get the forms via API using Scriptrunner. In general, Atlassian documentation is omitting one crucial part - formid which needs to be pulled first.
So, if anyone needs it, here's a code:
- pulls the form ID from an existing issue
- authenticates to api.atlassian.com
- pulls the form details
import javax.xml.bind.DatatypeConverter
def issueKey = XXX-123
def username = 'NAME'
def password = 'Auth Token'
def authString = "${username}:${password}"
def encodedAuthString = DatatypeConverter.printBase64Binary(authString.getBytes('UTF-8'))
def formId = get("/rest/api/2/issue/${issueKey}/properties/proforma.forms")
.header('Content-Type', 'application/json')
.asObject(Map).body
def id = formId.value.forms[0].uuid
def fields = get("https://api.atlassian.com/jira/forms/cloud/CLOUDID/issue/${issueKey}/form/${id}")
.header('Content-Type', 'application/json')
.header('Authorization', "Basic ${encodedAuthString}")
.header('X-ExperimentalApi', 'opt-in')
.asObject(Map).body
It pulls the first form, but you can iterate, etc. Hope it will make somebody's day easier ;)
thanks a lot for the sharing :-)
Online forums and learning are now in one easy-to-use experience.
By continuing, you accept the updated Community Terms of Use and acknowledge the Privacy Policy. Your public name, photo, and achievements may be publicly visible and available in search engines.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.