Aggregate functions in WIQL query - azure-devops

I want download WIQL report using REST API. REST response doesn't give all fields but it gives a list of URLS as workItems.
To get field values I need to download each WorkItem separately.
Any direct REST way to accomplish this in a single REST call?
Repeated REST calls gives me rate limiting or similar error. I get error 500 types after repeated GET request.
Genesis of this need is - There are no aggerate functions available likes of SUM, MAX, MIN, AVG Etc.

REST response doesn't give all fields but it gives a list of URLS as
workItems.
To get field values I need to download each WorkItem separately. Any
direct REST way to accomplish this in a single REST call?
Sorry but as I know, there's no direct rest api available to get WIQL report. An alternative workaround should be:
1.Use Query By Wiql to return the list of WorkItem IDs and Urls (I think this is the same rest api you use).
2.Then use Get Work Items Batch to get all the details(fields) about the requested work item ids. And here's one issue which has similar needs like yours, you can use the upgraded script from konpro11 to get list of IDs and use the IDs to get your report (with the help of second rest api).
Hope it helps :)

Related

Jama API - GET item with tag at the same time

I need to fetch items from JAMA API, and I do not get the Tag value with the data.
I tried to call GET/{item}/{id} API and then I also need to execute GET/{tags}/{id}/{item} to discover item tag, which takes too much time for multiple items.
Is there any more efficient way to get all data in one API call?
There is the /items/{id}/tags endpoint: https://rest.jamasoftware.com/#operation_getTagsOnItem

How to filter REST API JSON result by passing params

I'm trying to consume JIRA 2 API and trying to get custom fields. I want to further filter by passing appropriate criteria in URI itself. Current query I'm using is something similar to this:
http://localhost:8522/jira522/rest/api/2/issue/createmeta?expand=projects.issuetypes.fields
The result I'm getting from above request is about 2000 lines.. How can I further filter to get only Custom_fields and also under custom fields I need to only the ones which are required?
I'm pretty new to REST API. Please guide me If anything is wrong... TIA. I spent a lot of time browsing but don't know what exactly I need to search for or where exactly I need to get started.
You can use another queryParam just like expand and add further filtering or pagination.
http://localhost:8522/jira522/rest/api/2/issue/createmeta?expand=projects.issuetypes.fields&limit=1000

Possible to specify date_preset with insights edge in Facebook Ads API?

For the Marketing API, I know that I'm able to make one call to retrieve all of the adsets from a certain account along with their insights, but am I able to specify the date_preset for the insights edge in that same call?
For example, the following gives me lifetime insights stats:
/v2.4/{accountID}/adcampaigns?fields=insights
To be clear - I know this is possible to retrieve by making separate calls for each adset id (where I know I can specify the date_preset); instead, I'd like to do this via the call where I get a long list of the ad sets plus their insights details in one go.
Yes this is possible using query expansion, however you probably should not do it in this anyway.
Using query expansion results in multiple requests being executed in one HTTP call, in this case one to get all the adcampaigns, and then N requests where N is the number of adcampaigns returned. This will in turn affect your rate limiting.
The most efficient way to request all insights for all adcampaigns (ad sets) is instead to request them at the account level, specifying aggregation level:
/v2.4/act_{ADACCOUNT_ID}/insights?date_preset=last_7_days&level=campaign
This requires just 1 request, or the number of requests to retrieve the total number of pages.
If you really want to achieve this with query expansion, you can do the following for example:
/v2.4/act_{ADACCOUNT_ID}/adcampaigns?fields=insights.date_preset(last_30_days).time_increment(all_days)
You can see the parameters to insights that would normally be query parameters of the form param_name=param_value are now in the form of param_name(param_value).
To specify the date_preset , here is the correct format . Its important to use insights as edge to get the date_preset filtering .
/v2.10/act_{ADACCOUNT_ID}/insights?fields=impressions,clicks,ctr,unique_clicks,unique_ctr,spend,cpc&date_preset=last_3d
The above one is tested with latest Graph Api version(2.10) as of now . FOr more info related to the date_preset values refer to there api docs .
https://developers.facebook.com/docs/marketing-api/insights/parameters

How do i get the list of all the leads in Marketo

I want to get all leads in Marketo using their Rest Apis. Is there a way to do this? I have already tried the getLeadChanges api, however that only returns leads with changed fields.
Leads in Marketo are assigned lead ids in sequential order starting with 1. Using the Get Multiple Leads by Filter Type REST API endpoint, you can query 300 leads by lead id with each call.
You will have to specify id as the filterType and the lead ids as the filterValues with each call to this endpoint. To get all leads, you would iterate through the total number of leads 300 at a time.
The first API call would be (replace ... with all the values in between):
/rest/v1/leads.json?filterType=Id&filterValues=1,2,3,...,298,299,300
The second API call, and each subsequent API call would follow the same pattern:
/rest/v1/leads.json?filterType=Id&filterValues=301,302,303,...,598,599,600
By Marketo REST API you can request only static lists, and the "All leads" is dynamic.
Easyest way will be:
Create static list
Add all existing leads to this list
Create a Marketo campaign to add every new lead to this Static list.
then just query leads in this list. e.g.: https://%yourSubdomain%.mktorest.com/rest/v1/lists/%listId%/leads.json
Hope it will help.

Query multiple insights metrics in one API call

Is it possible to query more than one insights metric in one API call?
For example to get the daily added likes for a page I executed the following call:
https://graph.facebook.com/_object_id_/insights/page_fan_adds_unique/day/
But I would like to have another metric, e.g., page_fan_removes_unique, included as well.
Query the insights object entirely is a possibility, but gives me too much data I don't need, thus decreases performance.
Since your question shows that you're using the Graph API, you may want to use the batch requests method: http://developers.facebook.com/docs/reference/api/batch/
You can group multiple Graph API queries together so you can just query the Insights data you need in one request.
Yes, you can run a multiple FQL query in one API call and then parse the various results.
multi query: http://developers.facebook.com/docs/reference/rest/fql.multiquery/
insights table: http://developers.facebook.com/docs/reference/fql/insights/