This returns some JSON formatted stuff with a ‘ticket’ and a ‘CSRFPreventionToken’.
In subsequent requests, pass the ticket or the CSRFPreventionToken as a cookie:
curl -k -b “PVEAuthCookie=PVE:username@pam:4EEC61E2:…” https://10.0.0.1:8006/api2/json/
With Invoke-Restmethod, I was able to get the ticket. However, since the server does not actually set it as a cookie, the -Sessionvariable parameter leaves me with an empty cookiejar.
Gives me 2 variables:
$ticket.data -> Holds the tokens (ticket and CSRFPreventionToken)
$proxmox.Cookies -> System.Net.CookieContainer with 0 cookies in it.
I cannot find any useful information on the System.Net.CookieContainer, nor on the properties ‘Add’ or ‘SetCookies’…
How can I add a the two tokens from $ticket.data to my $proxmox.Cookies jar?
So… I mean, this is really kind of a .NET question, so it’s possible a site like StackOverflow will get you a more immediate answer. And, I know zip about ProxMox.
Thanks for the response, Don. I figured that I would look at some .Net stuff, but since I am not a developer, it is not really helpful Some if the MSDN documentation I found (and tried) included constructing cookies like: