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.
Related
If I navigate to /rest/api/2/issue/createmeta/PROJ/issuetype/N (in this case, I'm getting Task), the list of fields returned is incomplete. There are a number of customfields that are in use (I can see them both in the tickets themselves, and also in /plugins/servlet/project-config/PROJ/fields ) that are in the createmeta data.
I'm really trying to do this in python jira, where I'm using "expand='projects.issuetypes.fields'" in the createmeta() call, but I figured I'd double-check the results in the rest API directly, and I'm getting the same results there, too.
This is happening in jira 8.20.7.
Essentially, what I'm trying to do, is to programatically get a name/id mapping of all fields in the ticket type. I'm having far more difficulty doing that than I thought there would be. I would do it based on /rest/api/2/field but the jira admins have allowed some duplicated names...
EDIT: I realized that it might be worth noting that some of the fields I'm looking for are coming from a ServiceDesk form, although, as far as I can tell, there's no way to determine that, since one of the missing fields contains the name of the form.
Why are you using createmeta endpoint?
Instead of that, in order to get all of the customfields and their values; just note their id and get the values from /rest/api/2/issue/{issueKey} endpoint.
When you send a GET request to /rest/api/2/issue/{issueKey} endpoint, you will get a JSON object which contains "fields" object in it.
And using the "fields" you can determine all of the values that include system fields (description, assignee, etc.) and custom fields (like customfield_<customfieldid>).
And for a general approach, you may want to look at the field types in that response.
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)"
}
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'
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
I have developed an API using Microsoft Graph API. I am encountering below issue.
URL that I am calling :
/v1.0/sites/root/lists/cb32cc85-5351-423d-b2ec-bb418c1d9c64/items?
$filter=fields/Created gt '2018-1-1T00:00:00'
&expand=fields
&$orderby=createdDateTime
&$top=10
Error returned from the API :
Field 'Created' cannot be referenced in filter or orderby as it is not indexed. Provide the 'allowthrottleablequeries' preference to allow this, but be warned that such queries may fail on large lists.
How to enable allowthrottleablequeries as it says and how should I achieve this?
I'm afraid this isn't a very clear or useful error message. As far as I know, there isn't actually a way to enable allowthrottleablequeries.
This happens when a SharePoint list grows too large to handle filtering or sorting non-indexed columns. The fix is to add an index to the created column in your List Settings. You can find instructions on how to accomplish this in Add an index to a SharePoint column.
Try to send your request with following Request Header
Prefer: allowthrottleablequeries
If it does not work then try the following Request Header
Prefer: HonorNonIndexedQueriesWarningMayFailRandomly