Proxmox VE API: Difference between revisions

From Proxmox VE
Jump to navigation Jump to search
No edit summary
Line 24: Line 24:
}
}
</pre>
</pre>
You need to pass the returned ticket with a cookie to any further request:
<pre>
curl -k -b "PVEAuthCookie=PVE:root@pam:4EEC61E2::rsKoApxDTLYPn6H3NNT6iP2mv..." https://10.0.0.1:8006/api2/json/
</pre>
Additionally, any write request (POST, PUT, DELETE) must include the CSRFPreventionToken header:
<pre>
curl -XDELETE -H "CSRFPreventionToken: 4EEC61E2:lwk7od06fa1+DcPUwBTXCcndyAY" ...
</pre>




[[Category: Proxmox VE 2.0]]
[[Category: Proxmox VE 2.0]]

Revision as of 10:16, 17 December 2011

Yellowpin.svg Note: Article about Proxmox VE 2.0 beta

Introduction

http://pve.proxmox.com/pve2-api-doc/

tbd.

We will use the 'curl' command line tool for all examples.

Authentification

PVE uses a Token Based Authentication. All request to the API need to include that token inside a Cookie. We usually call that token a 'ticket'.

Additionally, any write request must include a CSRF prevention token inside the HTTP header.

Example: get a new ticket and the CSRF prevention token

# curl -k -d "username=root@pam&password=yourpassword"  https://10.0.0.1:8006/api2/json/access/ticket 
{ "data": { 
  "CSRFPreventionToken":"4EEC61E2:lwk7od06fa1+DcPUwBTXCcndyAY",  
  "ticket":"PVE:root@pam:4EEC61E2::rsKoApxDTLYPn6H3NNT6iP2mv...", 
  "username":"root@pam"}
}


You need to pass the returned ticket with a cookie to any further request:

curl -k -b "PVEAuthCookie=PVE:root@pam:4EEC61E2::rsKoApxDTLYPn6H3NNT6iP2mv..." https://10.0.0.1:8006/api2/json/

Additionally, any write request (POST, PUT, DELETE) must include the CSRFPreventionToken header:

curl -XDELETE -H "CSRFPreventionToken: 4EEC61E2:lwk7od06fa1+DcPUwBTXCcndyAY" ...