Jira Rest API JQL query - jira

I'm making use of the Jira API with the following call:
https://site.url/rest/api/2/search?jql=project=PROJECT&updated>=startOfWeek(-1w)
When I run this, I'm getting over 6000 results. But when I run the jql query of project = PROJECT AND updated >= startOfWeek(-1w) inside of my Jira sites search bar, I only get around 60 results.
Is there something I'm missing in my api call that would limit the returned to the data to the above query?
Edit
Looking further it appears my call is only bringing back results from my project space and not using the updated query. What should I do so it picks up both?

There is a typo in your query. You have used an ampersand instead of the word 'and'. The ampersand is the character used to add query parameters, so you effectively did this query
https://site.url/rest/api/2/search?jql=project=PROJECT
then Jira just ignored what came after the ampersand, as it didn't know what the parameter 'updated>' was, or how to make it equal 'startOfWeek(-1)'
Within the JQL, you must use the word 'and' with spaces before and after, like this:
https://site.url/rest/api/2/search?jql=project=PROJECT and updated>=startOfWeek(-1w)
Only use ampersands to add other query parameters afterwards, like this:
https://site.url/rest/api/2/search?jql=project=PROJECT and updated>=startOfWeek(-1w)&startAt=0&maxResults=500

Please send the API as POST method:
API: https://url/rest/api/2/search
Body:
{
"jql": "project='project name'&updated>=startOfWeek(-1)"
}

Related

JIRA and JQL: How can I filter results where custom fields are not empty?

I'm working on a get request that gives me all JIRA issues with the custom field "Sponsor". Since it's an optional field, the value is often empty. So out of all issues in a JIRA project, how can I extract those who have a sponsor? My query looks like this so far
https://jira.companyname.com/rest/api/2/search?jql=project=projectname&maxResults=1000
What is missing? I do know the customField name and id.
I tried
jql=project=projectname&maxResults=1000&customfield_number!%3DEMPTY
and
jql=project=projectname&maxResults=1000&customfield_number!%3Dnull
But it didn't work
Try is not EMPTY in your JQL query, rather than != null or !=EMPTY.
Substitute number for your custom field number and try this request URL: https://jira.companyname.com/rest/api/latest/search?jql=cf%5Bnumber%5D%20is%20not%20EMPTY
I finally figured it out thanks to someone who helped me in another forum.
The problem was that I treated the customfield parameter not as one in the jql query... So Adil's answer was correct, my problem was that I put cf%5Bnumber%5D%20is%20not%20EMPTYin the final part of the query. after maxResults.
Final URL that works for me looks like this:
https://jira.companyname.com/rest/api/2/search?jql=project=key+and+cf[id]+is+not+empty&maxResults=1000

How to quote colons in graph query

I have some code which gets details of lists in a SharePoint site then later wants to find out if a list with the same name still exists. This works fine except for list names that contain a colon - I find Graph misinterprets the colon and 'corrupts' the URL.
For instance, in Graph Explorer when I give it the following query:
https://graph.microsoft.com/v1.0/sites('mysite.sharepoint.com,aa-aa-aa,bb-bb-bb')/lists('19:abcdef#thread.tacv2_wiki')
The error response contains the following in the 'message' property:
The expression \"sites('mysite.sharepoint.com,aa-aa-aa,bb-bb-bb')/lists('19')/abcdef#thread.tacv2_wiki\" is not valid.
Note that it's split the original URL, thinking the colon is the start of a new segment in the path, even though it's inside a quote.
I've tried all sorts of quoting of the colon (%3A and %253A and %25253A) and different styles of quote characters, but they all either return the same error or give a parsing error.
More information - I specifically want to search by name not by original id (which would be much easier), I'm acutually using Graph Managed API in code but it generates the same error (you'd think it would internally know how to quote), the list is actually a hidden one created in a Teams site to manage channel information.
I was also able to reproduce your issue but as a work around you can use the filter query parameter to get the list by using below query.
https://graph.microsoft.com/v1.0/sites/soaadteam.sharepoint.com,c1178396-d845-46fa-bc0c-453d2951dad5,19ee9a1e-001d-48f1-9ee8-b0adfde54e45/lists?$filter=displayName eq '19:abcdef#thread.tacv2_wiki'

Retrieving More columns as Part of VSTS query

I'm trying to fetch details from VSTS using VSTS query API. So to get all Portfolio Epics I created a custom query and used its ID to get that in JSON format. the query looks like this
https://dev.azure.com/{organization}/{project}/{team}/_apis/wit/wiql/{id}?api-version=5.0-preview.2
But the issue is its not giving me many details about each of the work items in JSON. It only lists the ID and URL. Like this
WorkItems:[
{ID:234,URL:"workitemurl"},
{ID:235,URL:"workitemurl"},
{ID:236,URL:"workitemurl"},
...
]
So if I need more details about an item I need to execute those individual URl for each PE and thus I can get its details. instead of I am just checking is there is any way of getting an ID (keyedinID of each work item along with the ID and URL) like this. Please note KID is a field if we execute the URL separately. So to avoid that extra process, I would like to get that along with the WorkItems.
WorkItems:[
{ID:234,URL:"workitemurl",KID:002},
{ID:235,URL:"workitemurl",KID:023},
{ID:236,URL:"workitemurl",KID:033},
...
]
So how can we make this possible?
The Web UI uses a different API to get query results (/_api/_wit/_query), which allows query+data in a single pass. This is an old __v5 type call, which means it's considered internal.
The proper way to do this now is to first do the query as you're doing it right now and then call /_api/wit/workitems?ids=1,2,3,4 using the IDs from the references you got from the first call. That will also allow you to load the details dynamically and in small batches which will result in a more responsive UI.
See:
https://learn.microsoft.com/en-us/rest/api/azure/devops/wit/work%20items/list?view=azure-devops-rest-4.1

Get issues by label in Jira

I'm unable to get issues with needed label from REST API of Jira.
I'm sending GET request to the jira_url/rest/api/2/search?jql=project=MYPROJ&label=build1. In response I get 50 random items. I know that with this label exist only 2 items, but can't get them both.
I was serfing JIRA REST API documentation, but haven't found good examples how to get issues with items in array at least. Also tried the same via POST request with body:
{
"fields": [{"labels": ["build1"] }]
}
Tried similar examples from https://developer.atlassian.com/jiradev/jira-apis/jira-rest-apis/jira-rest-api-tutorials/jira-rest-api-example-query-issues
Any easy way to get the JQL Query String to use is to use the Issue Search UI and look at the generated URL at the top and to just grab the jql part:
So the part to add the labels section is:
%20AND%20labels%20in%20(build1%2C%20build2)
Which is and labels in (build1, build2). It is important to note that using the & makes the REST API things the JQL query parameter has ended which is why you need to use the space encoded character of %20 and then the AND keyword to build your JQL.

IMAP search on header not working as expected

I am building library for IMAP my search command works file for the Inbox folder it returns me a number which I can use to fetch the mail. However when I try to search on Sent Items it does not work it does not give an error but just returns Search OK without any numbers. Can you please point out why this behavior. I am hitting Exchange 2010.
My search command is something like:
search all HEADER Message-ID "<cc6aed80-955b-4800-a3ac-6c3942ceecac>"
This is exactly how it is described in http://support.microsoft.com/kb/302965
Possibly of no use, but I ran into possibly the same problem.
In a mailbox with an email from "Bill Gates ", a search with the expression '(FROM "billy#microsoft.com")' returned nothing; a search for '(FROM gates)' return a hit.
I had to change my code to '(HEADER FROM "billy#microsoft.com")' to get it to work.
ALTERNATIVELY:
You may be able to use IMAP4.uid(command, arg[, ...])
See http://docs.python.org/2/library/imaplib.html#imaplib.IMAP4.uid

Resources