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 ;)