Create
cancel
Showing results for 
Search instead for 
Did you mean: 
Sign up Log in

Using Forms via API

Lukasz Grobelny
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 14, 2023

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

1 comment

Frédéric Dubois
I'm New Here
I'm New Here
Those new to the Atlassian Community have posted less than three times. Give them a warm welcome!
December 23, 2023

thanks  a lot for the sharing :-)

Like Lukasz Grobelny likes this

Comment

Log in or Sign up to comment
TAGS
AUG Leaders

Atlassian Community Events