RESTful knowledge exchange
Post Reply
fermon
Novice
Posts: 5
Liked: never
Joined: Oct 11, 2014 2:47 am
Full Name: fermon grays
Contact:

Calling Restful API using linux curl

Post by fermon »

I'm having some difficulties with the syntax using linux. After generating a new login session with curl --get http://10.88.10.20:9399/api/ Next I issue the curl command Curl -H -D 'Authorization: Basic <Encoded string Here>' http://10.X.X.X:9399/api/sessionMngr/ .

The response I get is:

curl: (6) Could not resolve host: Authorization
<?xml version="1.0" encoding="utf-8"?><Error StatusCode="401" Message="Identity was not authenticated." xmlns="http://www.veeam.com/ent/v1.0" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
veremin
Product Manager
Posts: 20283
Liked: 2258 times
Joined: Oct 26, 2012 3:28 pm
Full Name: Vladimir Eremin
Contact:

Re: Calling Restful API using linux curl

Post by veremin »

Are you positive that the given account has the Portal Administrator, Portal User or Restore Operator role in the Enterprise Manager? Thanks.
poulpreben
Certified Trainer
Posts: 1024
Liked: 448 times
Joined: Jul 23, 2012 8:16 am
Full Name: Preben Berg
Contact:

Re: Calling Restful API using linux curl

Post by poulpreben »

This works for me:

Code: Select all

$ curl -XPOST -v -u user:pass http://10.0.0.7:9399/api/sessionMngr/?v=v1_1 -H "Content-Length: 0"
$ wget --method POST http://10.0.0.7:9399/api/sessionMngr/?v=v1_1 --http-user=user --http-password=pass --header="Content-Length: 0" -O - -S
Also, you do not create the logon session using the GET request mentioned. These two examples create the session and return the session token requires. Pro tip is that cURL actually supports the Set-Cookie header as well, so check the documentation for this feature to make your life much easier :)
poulpreben
Certified Trainer
Posts: 1024
Liked: 448 times
Joined: Jul 23, 2012 8:16 am
Full Name: Preben Berg
Contact:

Re: Calling Restful API using linux curl

Post by poulpreben » 2 people like this post

fermon wrote:Where did you find the uri info < ?v=v1_1 >
(Answering in the public forum instead of private message, since this might be valuable to other forum members too.)

A good way to discover and learn the API is using the built-in web client. The web client is available on http://enterprise-manager:9399/web or https://enterprise-manager:9398/web depending on whether you prefer HTTP or HTTPS.

Using this URL, you should see a screen similar to this:
Image

All the links can be used for navigation, and you will constantly be presented with a list of available resources. After creating the session using an empty POST session to the URL highlighted above, you will see the API overview. Most importantly, please note the <SessionId> tag at the bottom of the response.
Post Reply

Who is online

Users browsing this forum: No registered users and 2 guests