Rest API PHP call

RESTful knowledge exchange

Rest API PHP call

Veeam Logoby tdewin » Fri Jun 28, 2013 3:05 pm 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: 1043
Liked: 360 times
Joined: Fri Mar 02, 2012 1:40 pm
Full Name: Timothy Dewin

Re: Rest API PHP call

Veeam Logoby tdewin » Tue Jul 02, 2013 12:01 pm 1 person likes this post

Here is an updated version https://dl.dropboxusercontent.com/u/28976899/vrest_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
tdewin
Veeam Software
 
Posts: 1043
Liked: 360 times
Joined: Fri Mar 02, 2012 1:40 pm
Full Name: Timothy Dewin

Re: Rest API PHP call

Veeam Logoby sirinech » Tue Apr 22, 2014 12:59 pm

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: Fri Mar 21, 2014 3:06 pm
Full Name: sirine chadly

Re: Rest API PHP call

Veeam Logoby sirinech » Thu Apr 24, 2014 10:05 am

Image

Why I only get "the magic is starting here" and the rest ??
sirinech
Influencer
 
Posts: 23
Liked: 1 time
Joined: Fri Mar 21, 2014 3:06 pm
Full Name: sirine chadly

Re: Rest API PHP call

Veeam Logoby tdewin » Tue Apr 29, 2014 4:38 pm

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")
tdewin
Veeam Software
 
Posts: 1043
Liked: 360 times
Joined: Fri Mar 02, 2012 1:40 pm
Full Name: Timothy Dewin


Return to RESTful API



Who is online

Users browsing this forum: No registered users and 2 guests