Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[PowerShell] The body parameter of Invoke-RestMethod should be null, not an emtpy string when using Get requests. #146

Closed
JeromeLefebvre opened this issue Dec 27, 2019 · 2 comments
Labels

Comments

@JeromeLefebvre
Copy link

JeromeLefebvre commented Dec 27, 2019

Describe the bug
When doing a Get request, with an empty body and using the "PowerShell - RestMethod" code snippet, an error will be raised as the Invoke-Request method is improperly called.

To Reproduce

  1. Create a Get request to any ressource, say "example.com". The code generated will be:
$body = ""

$response = Invoke-RestMethod 'https://example.com/' -Method 'GET' -Headers $headers -Body $body
$response | ConvertTo-Json

The error returned by Powershell is the following:

Invoke-RestMethod : コンテンツ本体をこの verb-type では送信できません。
発生場所 行:3 文字:6
+ $a = Invoke-RestMethod 'https://example.com/' -Method 'GET' -Headers  ...
+      ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
    + CategoryInfo          : NotSpecified: (:) [Invoke-RestMethod], ProtocolViolationException
    + FullyQualifiedErrorId : System.Net.ProtocolViolationException,Microsoft.PowerShell.Commands.InvokeRestMethodCommand

Expected code snippet and corresponding request
This snippet instead works:

$body = $null

$response = Invoke-RestMethod 'https://example.com/' -Method 'GET' -Headers $headers -Body $body
$response | ConvertTo-Json

Additional context
Version of postman-code-generators/Postman app: 7.14.0

@webholik
Copy link
Contributor

@JeromeLefebvre I am not able to reproduce this. The request goes fine for Powershell v7.

@akshaydeo
Copy link
Contributor

@JeromeLefebvre closing this issue as we couldn't reproduce it. Feel free to re-open if you are still facing this issue 🙇‍♂

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

3 participants