Monitoring and reporting for Veeam Data Platform
Post Reply
Renan Oliveira
Novice
Posts: 3
Liked: never
Joined: Jul 26, 2023 12:44 pm
Full Name: Renan Bertucci de Oliveira
Contact:

Using Curl for GET HTTPS results on Veeam One

Post by Renan Oliveira »

Hi all,

I'm trying to use the REST API from Veeam one for get some informations. Below the command that I'm using with the result.

Code: Select all

C:\Users\feihgl6>curl -i -k -X GET https://10.132.17.105:1239/api/v1.0/about
HTTP/1.1 401 Unauthorized
Server:
WWW-Authenticate: Bearer
Strict-Transport-Security: max-age=31536000; includeSubDomains
X-Content-Type-Options: nosniff
X-XSS-Protection: 1; mode=block
Content-Security-Policy: default-src 'self'; script-src 'unsafe-inline' 'unsafe-eval' 'self'; style-src 'unsafe-inline' 'self'; object-src 'none'; base-uri 'none'; img-src 'self' data:; font-src 'self' data:; frame-src https:;
X-Powered-By:
X-Content-Type-Options: nosniff
X-XSS-Protection: 1; mode=block
Content-Security-Policy: default-src 'self'; script-src 'unsafe-inline' 'unsafe-eval' 'self'; style-src 'unsafe-inline' 'self'; object-src 'none'; base-uri 'none'; img-src 'self' data:; font-src 'self' data:; frame-src https:;
Strict-Transport-Security: max-age=31536000; includeSubDomains
Date: Fri, 28 Jul 2023 14:17:09 GMT
Content-Length: 0[/b]
I´m using this reference: https://helpcenter.veeam.com/docs/one/r ... #tag/About

Where I get this API_KEY? 'Authorization: YOUR_API_KEY_HERE'
RomanK
Veeam Software
Posts: 641
Liked: 168 times
Joined: Nov 01, 2016 11:26 am
Contact:

Re: Using Curl for GET HTTPS results on Veeam One

Post by RomanK »

Hello Renan,

It seems to me that you need to authenticate first and get a token from /api/token
Then apply this token as a bearer and curl would look like that
The curl would look like that
curl -X 'GET' \
'https://rk-lab-oneb.n.local:1239/api/v2.1/about' \
-H 'accept: application/json' \
-H 'Authorization: bearer eyJhbGciOiJIUzI1NiIsImtpZC...

In swagger it would look like that
Image

Thanks
jorgedlcruz
Veeam Software
Posts: 1372
Liked: 619 times
Joined: Jul 17, 2015 6:54 pm
Full Name: Jorge de la Cruz
Contact:

Re: Using Curl for GET HTTPS results on Veeam One

Post by jorgedlcruz »

Hello,
If you are trying to do more stuff with the API using curl, you can use the next script as starter, or orientation, it has how to obtain bearer, and how to query other things:
https://github.com/jorgedlcruz/veeam-on ... eam_one.sh

It is a bit old, but should work fine. Without this script, you will need to refresh token many times on the UI to come back to Curl, etc. Quite tricky.

Let us know
Jorge de la Cruz
Senior Product Manager | Veeam ONE @ Veeam Software

@jorgedlcruz
https://www.jorgedelacruz.es / https://jorgedelacruz.uk
vExpert 2014-2024 / InfluxAce / Grafana Champion
Renan Oliveira
Novice
Posts: 3
Liked: never
Joined: Jul 26, 2023 12:44 pm
Full Name: Renan Bertucci de Oliveira
Contact:

Re: Using Curl for GET HTTPS results on Veeam One

Post by Renan Oliveira »

Hi all,

I get the Token.

Code: Select all

C:\Users\feihgl6>curl -k -X POST "https://vwbranddone03.sa.vwg:1239/api/token" -H  "accept: application/json" -H  "Authorization: NOPASS" -H  "Content-Type: application/x-www-form-urlencoded" -d "username=NOUSER&password=NOPASS&rememberMe=true&grant_type=password&refresh_token="
{
  "access_token": "eyJhbGciOiJIUzI1NiIsImtpZCI6IldlYkFwaVNlY3VyaXR5S2V5IiwidHlwIjoiSldUIn0.eyJ1bmlxdWVfbmFtZSI6ImJydndiMDBcXGFlaWhnbDYiLCJyb2xlIjoiVGVuYW50IiwiaHR0cDovL3NjaGVtYXMueG1sc29hcC5vcmcvd3MvMjAwNS8wNS9pZGVudGl0eS9jbGFpbXMvc2lkIjoiUy0xLTUtMjEtMjA5NDUzOTcyMi02OTg0ODYxNjYtMTUyNDI0Nzk3Mi0yODU4MTIiLCJBY2Nlc3NUb2tlbklkIjoiNThkNDM1NWEtZDlmMi00Y2U2LWIxYjQtNTMzMmYxMDg0NzlkIiwiVXNlcklkIjoiMjAiLCJuYmYiOjE2OTA2NDYwNDUsImV4cCI6MTY5MDY0Njk0NSwiaWF0IjoxNjkwNjQ2MDQ1fQ.RDgEqwZ4jTT2dAZbeSdscnmHJTNXYYoe7g9s6lGPPiw",
  "refresh_token": "21ba1ab5c07e4da981e692f17a571e6f",
  "token_type": "Bearer",
  "expires_in": 899,
  "user": "NOUSER",
  "user_role": 4
}
Now to get the status about, I use the command line bellow?

Code: Select all

C:\Users\feihgl6>curl -k -X GET 'https://10.132.17.105:1239/api/v2.1/about' -H 'accept: application/json' -H 'Authorization: bearer eyJhbGciOiJIUzI1NiIsImtpZCI6IldlYkFwaVNlY3VyaXR5S2V5IiwidHlwIjoiSldUIn0.eyJ1bmlxdWVfbmFtZSI6ImJydndiMDBcXGFlaWhnbDYiLCJyb2xlIjoiVGVuYW50IiwiaHR0cDovL3NjaGVtYXMueG1sc29hcC5vcmcvd3MvMjAwNS8wNS9pZGVudGl0eS9jbGFpbXMvc2lkIjoiUy0xLTUtMjEtMjA5NDUzOTcyMi02OTg0ODYxNjYtMTUyNDI0Nzk3Mi0yODU4MTIiLCJBY2Nlc3NUb2tlbklkIjoiNGQzZDRiNzgtNjhjYS00MjM4LWIwNDktYWRiMDRjMTliNjVhIiwiVXNlcklkIjoiMjAiLCJuYmYiOjE2OTA2NDQ1MDYsImV4cCI6MTY5MDY0NTQwNiwiaWF0IjoxNjkwNjQ0NTA2fQ.yk_SDEvrGy7Z6Dl9h0LyKziPg5Ij5fLkH93VhZJ0qtE'
I do the download the json file too.

Bellow the result from command:

Code: Select all

curl: (3) URL rejected: Port number was not a decimal number between 0 and 65535
curl: (6) Could not resolve host: application
curl: (6) Could not resolve host: bearer
curl: (3) URL rejected: Bad hostname
Reference to Getting Authorization Tokens
https://helpcenter.veeam.com/docs/one/r ... ml?ver=120

Thanks.
Renan Oliveira
Novice
Posts: 3
Liked: never
Joined: Jul 26, 2023 12:44 pm
Full Name: Renan Bertucci de Oliveira
Contact:

Re: Using Curl for GET HTTPS results on Veeam One

Post by Renan Oliveira »

Hi,

Bellow the last result.

Code: Select all

C:\Users\feihgl6>curl -k -X GET "https://vwbranddone03.sa.vwg:1239/api/v2/about" -H  "accept: application/json" -H  "Authorization: Bearer eyJhbGciOiJIUzI1NiIsImtpZCI6IldlYkFwaVNlY3VyaXR5S2V5IiwidHlwIjoiSldUIn0.eyJ1bmlxdWVfbmFtZSI6ImJydndiMDBcXGFlaWhnbDYiLCJyb2xlIjoiVGVuYW50IiwiaHR0cDovL3NjaGVtYXMueG1sc29hcC5vcmcvd3MvMjAwNS8wNS9pZGVudGl0eS9jbGFpbXMvc2lkIjoiUy0xLTUtMjEtMjA5NDUzOTcyMi02OTg0ODYxNjYtMTUyNDI0Nzk3Mi0yODU4MTIiLCJBY2Nlc3NUb2tlbklkIjoiZDdkZWNiNjctNzVmZi00ZjEzLWE5YzctMjA0Nzc5ZWEyMjQ4IiwiVXNlcklkIjoiMjAiLCJuYmYiOjE2OTA2NTk4MzksImV4cCI6MTY5MDY2MDczOSwiaWF0IjoxNjkwNjU5ODM5fQ.aXZ606HemB83otvDSCWMDsFPWaFS6h9qVbIDSfH34gA"
{"type":"about:blank","title":"This method is not allowed for users with \"Tenant\" role","status":403,"detail":"This method is not allowed for users with \"Tenant\" role","instance":"/api/v2/about","extensions":{"exceptionType":"AccessDeniedException"}}
RomanK
Veeam Software
Posts: 641
Liked: 168 times
Joined: Nov 01, 2016 11:26 am
Contact:

Re: Using Curl for GET HTTPS results on Veeam One

Post by RomanK »

Hello Renan,

In the current release, there is no access to the Rest API for tenant accounts.
The account must be a member of the Veeam ONE Administrators, Veeam ONE Power Users or Veeam ONE Read-Only Users group. Some methods would not be accessible for the latest two groups.

Thanks
jorgedlcruz
Veeam Software
Posts: 1372
Liked: 619 times
Joined: Jul 17, 2015 6:54 pm
Full Name: Jorge de la Cruz
Contact:

Re: Using Curl for GET HTTPS results on Veeam One

Post by jorgedlcruz » 1 person likes this post

To what Roman mentioned, be careful next time sharing the first query to obtain the bearer, as you pasted your user/pass in plain text, I just edited removing it.

Let us know
Jorge de la Cruz
Senior Product Manager | Veeam ONE @ Veeam Software

@jorgedlcruz
https://www.jorgedelacruz.es / https://jorgedelacruz.uk
vExpert 2014-2024 / InfluxAce / Grafana Champion
Post Reply

Who is online

Users browsing this forum: No registered users and 8 guests