RESTful knowledge exchange
Post Reply
tdewin
Veeam Software
Posts: 1775
Liked: 646 times
Joined: Mar 02, 2012 1:40 pm
Full Name: Timothy Dewin
Contact:

Rest API PHP call

Post by tdewin » 1 person likes this post

Very very easy example I hacked together. At least I got logged in :D but not deleting the session so not that clean yet. :)

Image
https://dl.dropboxusercontent.com/u/289 ... %20api.zip
tdewin
Veeam Software
Posts: 1775
Liked: 646 times
Joined: Mar 02, 2012 1:40 pm
Full Name: Timothy Dewin
Contact:

Re: Rest API PHP call

Post by tdewin » 1 person likes this post

Here is an updated version https://dl.dropboxusercontent.com/u/289 ... _start.zip

It contains an example vrest_start.php that will start a job via the rest api. Basically the simple example in PHP. In vrest_start.php I also added the code to log out. Could be useful if you want to use a linux scheduler. However it is still async. The task I get back from Enterprise manager just seems to "wait" (task status = finnished) until the backup command has been acknowledged by the backup server.

Image
sirinech
Influencer
Posts: 23
Liked: 1 time
Joined: Mar 21, 2014 3:06 pm
Full Name: sirine chadly
Contact:

Re: Rest API PHP call

Post by sirinech »

Hello I tried to use the vrest.zip but I get this error when executing; php vrest_start.php BackupJob

"fatal error call to undefined method Guzzle\Common\Exception\RuntimeException::getResponse() in vrest_start.php"
sirinech
Influencer
Posts: 23
Liked: 1 time
Joined: Mar 21, 2014 3:06 pm
Full Name: sirine chadly
Contact:

Re: Rest API PHP call

Post by sirinech »

Image

Why I only get "the magic is starting here" and the rest ??
tdewin
Veeam Software
Posts: 1775
Liked: 646 times
Joined: Mar 02, 2012 1:40 pm
Full Name: Timothy Dewin
Contact:

Re: Rest API PHP call

Post by tdewin »

Long time I wrote this but reviewed it quickly. Basically it means you are successfully loading the guzzle library but nothing has happened yet :)

Make sure you have changed the username and password in the file because if the login fails, it won't do anything (if ($login != "") but no else statement saying something like "login failed")
Post Reply

Who is online

Users browsing this forum: No registered users and 3 guests