Forums

Articles
Create
cancel
Showing results for 
Search instead for 
Did you mean: 

How to get the all the project name details using the RestAPI

Senthil V March 11, 2019

Hi,

Am using the jira module in python to get the all project details using for one custom field, the python coding will be like below,

fieldid=cf[XXXXX]
associated_projects = []
JQL="%s is not EMPTY order by updated" % (fieldid)
issues = jira.search_issues(JQL, maxResults=1, fields="issue key")
for issue in issues:
jira_issue = jira.issue(issue.key, fields='project')
project_key = jira_issue.fields.project.key
print ("Project Key", project_key)
associated_projects.append(str(project_key))

associated_projects list have all project name details, from this above code it will take more time to fetch the all project name one by one, whether this same needs to done in one single Rest API call? to get the all project name detail for customfiled.
So that we could save the more time.

1 answer

0 votes
Tarun Sapra
Community Champion
March 11, 2019
Senthil V March 11, 2019

Hi Tarun Sapra,

Thanks for the information sharing, but i need some restriction is jql query.

JQL="%s is not EMPTY order by updated" % (fieldid)

I want to form this jql query like above to get the project details.

Tarun Sapra
Community Champion
March 11, 2019

Hello @Senthil V 

But the JQL query is only going to give you issues and from those issues which can get the project keys.

In your code here

jira_issue = jira.issue(issue.key, fields='project')
project_key = jira_issue.fields.project.key
print ("Project Key", project_key)

You are only getting the project key, which you can also get from the issue key (ABC-123) in this issue key "ABC" is the project. So you can do one REST call based on the JQL and then parse the results of all issueKeys returned and each of the issueKey contains the project key as well thus you are doing everything in just one REST call.

Senthil V March 11, 2019

Hi Tarun Sapra,

Can you share Rest API for the same thing mentioned above. I don't have knowledge to get the same thing Rest API by step by step. It could be very help full for me.

Senthil V March 11, 2019

Hi Tarun Sapra,

 

I am trying with below RestAPI, but am not getting all the project or issues name

https://domainname/rest/api/2/search?jql=cf[xxxxx]+is+not+EMPTY+order+by+updated&validateQuery=True&startAt=0&fields=issue+key&maxResults=1000

and also only showing 20 record only

Tarun Sapra
Community Champion
March 11, 2019

Hello @Senthil V 

See some samples here

https://developer.atlassian.com/server/jira/platform/jira-rest-api-examples/#searching-for-issues-examples

http://localhost:8080/rest/api/2/search?jql=assignee=charlie

Can you try the REST call in the web browser, is it showing the same number of results as in the issue navigator view for your JQL. 

Senthil V April 25, 2019

Hi Tarun Sapra,

 

Is there any SQL query is there to get the all project details using the single custom filed.

 

Regards,

Senthil V

Suggest an answer

Log in or Sign up to answer
TAGS
AUG Leaders

Atlassian Community Events