Getting fields in a screen scheme using JIRA Java Rest Client

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

Accepted Answer
1 vote

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

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

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

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.

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.

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

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
Community showcase
Posted Sep 25, 2018 in Jira

Atlassian Research Workshop opportunity on Sep. 28th in Austin, TX

We're looking for participants for a workshop at Atlassian! We need Jira admins who have interesting custom workflows, issue views, or boards. Think you have a story to sha...

466 views 7 5
Join discussion

Atlassian User Groups

Connect with like-minded Atlassian users at free events near you!

Find a group

Connect with like-minded Atlassian users at free events near you!

Find my local user group

Unfortunately there are no AUG chapters near you at the moment.

Start an AUG

You're one step closer to meeting fellow Atlassian users at your local meet up. Learn more about AUGs

Groups near you