Using $Select and $Filter together

suvra jyoti 156 Reputation points
2021-05-31T09:04:36.98+00:00

Hi,

I am using the below Azure APIM Rest API for getting API usage by API Operation

https://learn.microsoft.com/en-us/rest/api/apimanagement/2019-12-01/reports/listbyoperation

Below is my Request Uri:

var requestUri = String.Format("reports/byOperation?$filter=timestamp ge datetime'2021-05-19T00:00:00' and timestamp le datetime'2021-05-21T00:00:00' and subscriptionId eq '{0}'&$orderby=callCountTotal desc&api-version=2019-12-01&$top=20", subscription);

This returns me the response having below fields.

"value": [
{
"name": "abcd",
"apiId": "/apis/95bf5ea7295646b8acd33dd6d6d18b74",
"operationId": "/apis/95bf5ea7295646b8acd33dd6d6d18b74/operations/abcd",
"callCountSuccess": 0,
"callCountBlocked": 0,
"callCountFailed": 0,
"callCountOther": 0,
"callCountTotal": 0,
"bandwidth": 0,
"cacheHitCount": 0,
"cacheMissCount": 0,
"valueCacheHitCount": 0,
"valueCacheMissCount": 0,
"apiTimeAvg": 0.0,
"apiTimeMin": 0.0,
"apiTimeMax": 0.0,
"serviceTimeAvg": 0.0,
"serviceTimeMin": 0.0,
"serviceTimeMax": 0.0
},
{
"name": "efghijk",
"apiId": "/apis/1b17047c23de4a3b9b77f2d4063376da",
"operationId": "/apis/1b17047c23de4a3b9b77f2d4063376da/operations/efghijk",
"callCountSuccess": 0,
"callCountBlocked": 0,
"callCountFailed": 0,
"callCountOther": 0,
"callCountTotal": 0,
"bandwidth": 0,
"cacheHitCount": 0,
"cacheMissCount": 0,
"valueCacheHitCount": 0,
"valueCacheMissCount": 0,
"apiTimeAvg": 0.0,
"apiTimeMin": 0.0,
"apiTimeMax": 0.0,
"serviceTimeAvg": 0.0,
"serviceTimeMin": 0.0,
"serviceTimeMax": 0.0
},
]

How can I get a response that has only these below fields?

  "name": "abcd",  
  "apiId": "/apis/95bf5ea7295646b8acd33dd6d6d18b74",  
  "operationId": "/apis/95bf5ea7295646b8acd33dd6d6d18b74/operations/abcd",  
  "callCountTotal": 0  

I understand we can apply $Select for the same, but how should i apply the same along with $filter? I am facing issues like "Invalid select clause". Providing an example will be a lot of help.

Thanks,
SuvraJyoti

Azure API Management
Azure API Management
An Azure service that provides a hybrid, multi-cloud management platform for APIs.
2,446 questions
{count} votes

Your answer

Answers can be marked as Accepted Answers by the question author, which helps users to know the answer solved the author's problem.