Create Logon Session with curl php

RESTful knowledge exchange

Create Logon Session with curl php

Veeam Logoby sirinech » Fri May 16, 2014 11:05 am

Hello Every Body, I'm trying to get the X-RestSession using curl php :
Code: Select all
$ch = curl_init();
$curlConfig = array(
    CURLOPT_URL            =>     $url,
   CURLOPT_VERBOSE        => true,
   CURLOPT_HEADER         => true,
    CURLOPT_POST           =>  true,
    CURLOPT_RETURNTRANSFER => true,
   
);
curl_setopt_array($ch, $curlConfig);
curl_setopt($ch, CURLOPT_HTTPAUTH, CURLAUTH_BASIC);
curl_setopt($ch, CURLOPT_HTTPHEADER,
            array(
         'HTTP_AUTH_LOGIN: '.$login,
            'HTTP_AUTH_PASSWD: '.$passwd,
            'Content-Type: application/xml; charset=utf-8',
            'Content-Length: '.strlen($data),
            'Authorization: Basic '.$data,
));

 
curl_exec($ch);

But I get this screen:
https://www.dropbox.com/s/mkgtbnwvg3lix75/test.png

What could be the problem??
sirinech
Influencer
 
Posts: 23
Liked: 1 time
Joined: Fri Mar 21, 2014 3:06 pm
Full Name: sirine chadly

Re: Create Logon Session with curl php

Veeam Logoby sirinech » Sat May 17, 2014 8:08 pm

I changed the code to this and it worked but I don't see the X-RestSvcSessionId in the response header how do I get it?
sirinech
Influencer
 
Posts: 23
Liked: 1 time
Joined: Fri Mar 21, 2014 3:06 pm
Full Name: sirine chadly

Re: Create Logon Session with curl php

Veeam Logoby sirinech » Sat May 17, 2014 9:30 pm 1 person likes this post

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

Re: Create Logon Session with curl php

Veeam Logoby clh_jl » Mon Sep 22, 2014 12:50 pm

What was the solution?
clh_jl
Service Provider
 
Posts: 14
Liked: 2 times
Joined: Mon Sep 22, 2014 12:49 pm

Re: Create Logon Session with curl php

Veeam Logoby v.Eremin » Mon Sep 22, 2014 2:42 pm

Are experiencing any problems while trying to create logon session via cURL? The following request should work fine, at least it does so in my case (I'm using Windows cURL client):

Code: Select all
curl -XPOST -v -u user:password http://EM:9399/api/sessionMngr/ -H "Content-Length: 0"


Thanks.
v.Eremin
Veeam Software
 
Posts: 13266
Liked: 968 times
Joined: Fri Oct 26, 2012 3:28 pm
Full Name: Vladimir Eremin

Re: Create Logon Session with curl php

Veeam Logoby clh_jl » Wed Sep 24, 2014 2:40 pm

Hi,

Thanks for the reply. I was looking to do something similar using PHP - however, I have since realised that there are a large number of code samples provided as part of the Veeam EM installation (C:\Program Files\Veeam\Backup and Replication\Enterprise Manager\samples) which I used to connect instead.

Thanks.
clh_jl
Service Provider
 
Posts: 14
Liked: 2 times
Joined: Mon Sep 22, 2014 12:49 pm

Re: Create Logon Session with curl php

Veeam Logoby v.Eremin » Wed Sep 24, 2014 4:19 pm

Glad to hear you've nailed. Don't forget to utilize our [url="http://helpcenter.veeam.com/backup/70/rest/"]Help Center[/url] to learn more about syntax and available entities. Thanks.
v.Eremin
Veeam Software
 
Posts: 13266
Liked: 968 times
Joined: Fri Oct 26, 2012 3:28 pm
Full Name: Vladimir Eremin


Return to RESTful API



Who is online

Users browsing this forum: No registered users and 4 guests