skip to Main Content

For some reason when request is sent through Swagger it goes through without any issues
enter image description here

But when I try to do the same thing with powershell I get 400

curl -Method Post -Uri "http://localhost:32774/WeatherForecast" -Headers @{ accept = '*/*';"Content-Type" ="application/json" } -Body "test"

enter image description here

What can I do to fix it?

2

Answers


  1. Chosen as BEST ANSWER

    Sending post though Powershell curl

    This comment is the answer. What I was missing were quotes in body. I wish I could mark the comment as answer.


  2. Try

    $response = Invoke-RestMethod -Uri "http://localhost:32774/WeatherForecast" -Method POST -Headers @{ accept = '*/*' } -ContentType 'application/json'
    
    Login or Signup to reply.
Please signup or login to give your own answer.
Back To Top
Search