Hello EpiUsers
I have an email being generated by PowerShell of REST data. You can find the details here: REST to email
When I try to add a REST $filter, PowerShell errors out.
This works without any parameter limitation - wide open: Invoke-RestMethod -Uri https://XXXX/EpicorERP10/api/v1/BaqSvc/EstimatorEmail/ -Credential $Cred -ContentType "Application/Json; charset=UTF-8"
This works with certain columns selected $select: Invoke-RestMethod -Uri https://XXXX/EpicorERP10/api/v1/BaqSvc/EstimatorEmail/?%24select=JobAsmbl_JobNum%2CJobHead_PartNum -Credential $Cred -ContentType "Application/Json; charset=UTF-8"
I can even $filter based on numeric values successfully: Invoke-RestMethod -Uri https://XXXX/EpicorERP10/api/v1/BaqSvc/EstimatorEmail/?%24filter=Calculated_Total_Actual_Hours%20eq%200 -Credential $Cred -ContentType "Application/Json; charset=UTF-8"
But when I try to $filter with a string it errors out: Invoke-RestMethod -Uri https://XXXX/EpicorERP10/api/v1/BaqSvc/EstimatorEmail/?%24filter=ECORev_ECO%20eq%20'Eric' -Credential $Cred -ContentType "Application/Json; charset=UTF-8"
Here is the error message in PowerShell:
At line:9 char:9
+ $data = Invoke-RestMethod -Uri https://XXXX/E ...
+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+ CategoryInfo : InvalidOperation: (Method: GET, Reques\u2026YnN0b2hyOm1pZGk=
}:HttpRequestMessage) [Invoke-RestMethod], HttpResponseException
+ FullyQualifiedErrorId : WebCmdletWebResponseException,Microsoft.PowerShell.Commands.InvokeRestMethodCommand```
I'm copying directly from the swagger page and it works there.
Any thoughts?
When it has already changed $ to %24. And then THAT gets sent to the UrlEncode utility it goes further into chaos because it changes the ā%ā of %24 through another round of decoding that results in ā%2524ā. I donāt think that helps get a usable result in the Invoke method.
I feel like Iām way in the weeds nowā¦
So, an interesting thing happens on the way back to the Encoder. The $select and $filter get recognized and ignored. This renders the URL unusable. The result skips right over the green highlighted text and moves on to the next character.
Ughā¦
Seems Iāve hit the overlap between the Powershell āuses $ for the variableā and ignores it and REST āuses $ for a commandā
Well, hereās where Iām at with all this.
If I only replace ā with %27 around the text of my $filter like you showed, then Iām doing very little to the Swagger URL and Iām happy.
Itās only when I tried to also use $select to massage the columns that I got into trouble.
Iām weeding out unwanted data columns in the ConvertTo-Html step instead using -Property