Getting fields in a screen scheme using JIRA Java Rest Client

Hamza KOHEN May 6, 2013

Hello,

Im curently using JIRA Java Rest CLient and i want to get all fields present in a screen ( linked to a screen scheme for example) . So to be clear, i have a screen named "myScreen" which contains fields and i want to get those fields using JIRA Java Rest Client.

Thanks in advance,

Hamza

2 answers

1 accepted

1 vote
Answer accepted
Hamza KOHEN May 6, 2013

Hello guys. I eventually found out the answer. I'm using , in fact, Jira Java Rest Client and i retrieve now all the fields linked to an issue type using the code below:

GetCreateIssueMetadataOptions  options = new GetCreateIssueMetadataOptionsBuilder()
		.withExpandedIssueTypesFields()
		
		.withProjectKeys("CGIM")
		.build();
         List myList=(List) restClient.getIssueClient().getCreateIssueMetadata(options, pm); // getting the issue creation metadata relatively to the project im searching for
        java.util.Iterator<CimProject> it1=myList.iterator();
        while(it1.hasNext())
        {
        		CimProject c=it1.next();
        		List issueT=(List) c.getIssueTypes(); // getting the list of issue types linked to this project
        		java.util.Iterator<CimIssueType> it2=issueT.iterator();
            	while (it2.hasNext())
            	{
            		CimIssueType issueType=it2.next();
            		System.out.print(issueType.getName());
            		Map<String, CimFieldInfo> fieldList=issueType.getFields(); // getting the list of fields linked to each issue type 
            		for(Entry<String, CimFieldInfo> entry : fieldList.entrySet()) {
            		    String cle = entry.getKey();
            		    CimFieldInfo valeur = entry.getValue();
            		    System.out.println(valeur.getName());
            		}
            	}

        	
        }

Hope i could help someone who's searching for the same thing and thank you all for your help.

2 votes
John Chin
Atlassian Team
Atlassian Team members are employees working across the company in a wide variety of roles.
May 6, 2013

Hi Hamza,

I guess you can try to use REST API below to get the available fields:

/rest/api/2/screens/{screenId}/availableFields

https://docs.atlassian.com/jira/REST/latest/#id102121

Hope its helps.

Thanks, John

Hamza KOHEN May 6, 2013

Hi John, thanks for your answer. can you just tell me how to use such querie in a java project for example?

Jobin Kuruvilla [Adaptavist]
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.
May 6, 2013
Jobin Kuruvilla [Adaptavist]
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.
May 6, 2013

The method is what John suggested. The above post only says how you can use Jersey to access methods from Java. You need to combine both.

Hamza KOHEN May 6, 2013

No it actually didn't help. currently i can access issues usig jira java rest client. But my purpose is to have the list of the fields present in a screen that i did define. Im still strugling to find a method to do so.

Hamza KOHEN May 6, 2013

Ok I'll try it and give you a feedback ASAP. Thanks to both of you .

Kandarp Gandhi July 9, 2015

I am looking exactly for such a code. I tried using above snippet but didnt work. any suggestions?

Suggest an answer

Log in or Sign up to answer