Thursday, February 1, 2024

cUrl on Powershell

It is sometimes handy to run curl commands from PowerShell. 

Couple things you need to watch out for - 

1) The curl command is aliased to Invoke-WebRequest. If you really want use curl natively, then run this command in your PowerShell window first. 

remove-item alias:curl 

2) If you are POSTing or PUTing raw JSON in the body, then it helps to store the raw json in a file and passing it as a parameter via the -T option. Below is an example 

curl --location --request PUT 'https://Yourendpoint' --header 'Authorization: Bearer <yourtoken>' --header 'Content-Type: application/json' -T 'C:\temp\abc.txt' 

If you use Postman, you can generate the curl command or in other programming languages as well. 

blog@aileronconsulting.com

No comments:

Post a Comment

We welcome your comments.