REST API knowledge exchange
Post Reply
sirinech
Influencer
Posts: 23
Liked: 1 time
Joined: Mar 21, 2014 3:06 pm
Full Name: sirine chadly
Contact:

Create Logon Session with curl php

Post by sirinech »

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

Re: Create Logon Session with curl php

Post by sirinech »

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

Re: Create Logon Session with curl php

Post by sirinech » 1 person likes this post

Solved
clh_jl
Service Provider
Posts: 14
Liked: 2 times
Joined: Sep 22, 2014 12:49 pm
Contact:

Re: Create Logon Session with curl php

Post by clh_jl »

What was the solution?
veremin
Product Manager
Posts: 20415
Liked: 2302 times
Joined: Oct 26, 2012 3:28 pm
Full Name: Vladimir Eremin
Contact:

Re: Create Logon Session with curl php

Post by veremin »

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.
clh_jl
Service Provider
Posts: 14
Liked: 2 times
Joined: Sep 22, 2014 12:49 pm
Contact:

Re: Create Logon Session with curl php

Post by clh_jl »

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.
veremin
Product Manager
Posts: 20415
Liked: 2302 times
Joined: Oct 26, 2012 3:28 pm
Full Name: Vladimir Eremin
Contact:

Re: Create Logon Session with curl php

Post by veremin »

Glad to hear you've nailed. Don't forget to utilize our Help Center to learn more about syntax and available entities. Thanks.
Post Reply

Who is online

Users browsing this forum: No registered users and 1 guest