0

I am trying to request information from one of our APIs using JSON however there is a lot which needs to be filtered out.

According to our API documentation, we have an "IncludeFields" query. How can I make it so when the information is requested, only information with "CS505MA001" is returned instead of the 100s of objects I'm getting.

$CommcellInfo = Invoke-RestMethod -Method Get -Uri $URL -Headers @{ "X-    Auth-Token" = $Global:AuthToken; "includeFields" = "CS505MA001" } 

$Include_Query = @{"includeFields"="CS505MA001"}
$ConvertedInclude_Query = ConvertTo-Json $Include_Query
$CommcellInfo = Invoke-RestMethod -Method Get -Uri $URL -Headers @{ "X-Auth-Token" = $Global:AuthToken } 

I am trying to only show the returned information which contains certain text, how would I go about achieving this?

Mike
  • 207
  • 1
  • 4
  • 16
  • Possible duplicate of [How to use GET method of Invoke-WebRequest to build a query string](https://stackoverflow.com/questions/32442777/how-to-use-get-method-of-invoke-webrequest-to-build-a-query-string) – Tomalak Mar 26 '19 at 15:58
  • I don't think you need to convert anything to JSON here. If the API documentation speaks of a "query" it's likely they mean the query string, i.e. regular key-value pairs. – Tomalak Mar 26 '19 at 15:59
  • You should just be able to add query parameters to the `-Body` parameter: `$CommcellInfo = Invoke-RestMethod -Method Get -Uri $URL -Headers @{ "X-Auth-Token" = $Global:AuthToken } -Body $Include_Query`. – AdminOfThings Mar 26 '19 at 22:50
  • When I try to add this to the body switch I get the following error: – Mike Mar 28 '19 at 12:49

0 Answers0