toenuff / flancy

A micro web framework for Windows PowerShell
MIT License
189 stars 21 forks source link

Errors on invoking the example #9

Closed nightroman closed 8 years ago

nightroman commented 9 years ago

It's probably work in progress but I better let you know. On invoking example.ps1 I get the below errors. I am using PowerShell v3, if it matters.

Invoke-RestMethod : The 'Accept' header must be modified using the appropriate property or method.
Parameter name: name
At C:\-\GIT\flancy\example.ps1:45 char:1
+ Invoke-RestMethod -Uri http://localhost:8001/process -Headers @{'Accept'='applic ...
+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
    + CategoryInfo          : NotSpecified: (:) [Invoke-RestMethod], ArgumentException
    + FullyQualifiedErrorId : System.ArgumentException,Microsoft.PowerShell.Commands.InvokeRestMethodCommand

Invoke-RestMethod : The 'Accept' header must be modified using the appropriate property or method.
Parameter name: name
At C:\-\GIT\flancy\example.ps1:46 char:1
+ Invoke-RestMethod -Uri http://localhost:8001/process -Method Post -Body "Notepad ...
+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
    + CategoryInfo          : NotSpecified: (:) [Invoke-RestMethod], ArgumentException
    + FullyQualifiedErrorId : System.ArgumentException,Microsoft.PowerShell.Commands.InvokeRestMethodCommand
nightroman commented 9 years ago

Tried on v4 and v5, it works. It may be v3 issue.

ducke commented 9 years ago

Yes is fixed in v4 https://connect.microsoft.com/PowerShell/feedback/details/757249/invoke-restmethod-accept-header

toenuff commented 9 years ago

I'll probably just remove the header sample - while it's correct, it's not really necessary. Invoke-RestMethod without it will still get the same results. It's really only needed for something that implements the ability for the client to change the content type based on the requesting headers.

toenuff commented 8 years ago

Wound up leaving the -headers. The problem is that without them, the system freezes when running the script after the post example. I can add a sleep to fix it, but instead I simply added a comment that in V3 and earlier you cannot use these headers. I also added a note that it will work without those headers in v3. No note about the unexpected behaviors that might happen, but I think it's ok.