emaksovalec's Blog

emaksovalec's Avatar Image
Emacs fan from Slovenia. Interested in #linux #emacs #lisp #scheme and so on :)
← All posts

#powershell vs. unix scripting: calling a REST API endpoint and wanting to see full response even in case of 400-500 response type.

linux: curl -i http://localhost/api/foo

powershell: try { Invoke-WebRequest -UseBasicParsing “http://localhost/api/foo” } catch [System.Net.WebException] {$webExObj = $_.Exception; $webExObj.Response; [System.IO.StreamReader]::new($webExObj.Response.GetResponseStream()).ReadToEnd()}

would love to use some better approach for PS but that is all I got currently

To like or reply, open original post on Emacs.ch