Home > Software design >  How do you filter a rest api call?
How do you filter a rest api call?

Time:09-29

Using the Usage Details Rest API:

https://docs.microsoft.com/en-us/rest/api/consumption/usage-details/list

In PowerShell, I have a call that looks like this:

Param=@{
  Method = 'Get'
  Uri = $MyUri
Headers = @{
  Authorization = "Bearer"   $Token
}

Request = Invoke-RestMethod @Param

My question is, with the API in the URL above, how do I filter in information for the date into the above code?

CodePudding user response:

Thank you Daniel & Cpt.Whale Posting your suggestion as an answer to help other community members.

Based on this Microsoft documentation;

"You just need to set (For example):?$filter=properties/usageStart ge '2020-02-01' and properties/usageEnd le '2020-02-29' in your $MyUri ."

  • Related