user2463506
user2463506

Reputation: 129

Sending post though Powershell curl

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?

Upvotes: 0

Views: 68

Answers (2)

user2463506
user2463506

Reputation: 129

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.

Upvotes: 1

Robert
Robert

Reputation: 173

Try

$response = Invoke-RestMethod -Uri "http://localhost:32774/WeatherForecast" -Method POST -Headers @{ accept = '*/*' } -ContentType 'application/json'

Upvotes: 0

Related Questions