RESTful knowledge exchange
Post Reply
DTTS
Novice
Posts: 4
Liked: never
Joined: Jul 01, 2020 8:03 am
Full Name: Dickson Tan
Contact:

Questions on API and how it works for End User GUI (#04316494)

Post by DTTS »

(#04316494)
Hi team,

Currently I am doing a GUI for my own practices with Javascript Programming language and I am trying to link the data with Veeam Backup Enterprise Manager.
I have refer the Veeam Backup API reference on
(https://helpcenter.veeam.com/docs/backu ... ml?ver=100)
and I do not know which one have to link it first and how it works. Also i got a bit confuse which one link have to link to the right direction.
Correct me if i got a misunderstood with the link that do not work like that.

Thank you team.
oleg.feoktistov
Veeam Software
Posts: 1912
Liked: 635 times
Joined: Sep 25, 2019 10:32 am
Full Name: Oleg Feoktistov
Contact:

Re: Questions on API and how it works for End User GUI (#04316494)

Post by oleg.feoktistov »

Hi Dickson,

I'm not sure I understood the question entirely. But if you are asking about requests workflow and structure, here is the deal:
- Perform logon. Send POST request to /api/sessionMngr/?v=latest with the corresponding headers.
- Obtain X-RestSvcSessionId response header and include it in each subsequent header of the request.
- As soon as obtained, it's up to you what to show the user and which resources to fetch.

You could take a look at Postman tool. Really helpful if you need to test API and develop client/server code.

Please let me know if I wrongly understood your question and elaborate on it.

Thanks,
Oleg
DTTS
Novice
Posts: 4
Liked: never
Joined: Jul 01, 2020 8:03 am
Full Name: Dickson Tan
Contact:

Re: Questions on API and how it works for End User GUI (#04316494)

Post by DTTS »

Hi Oleg,

Thanks for replying and I am using the Postman tools already but not familiar with it.
I am using postman tools and i am not sure where to obtain X-RestSvcSessionId, is it have to key in under the Headers Column under the Key field there?
Correct me if i got any mistakes.

Thank you very much.
oleg.feoktistov
Veeam Software
Posts: 1912
Liked: 635 times
Joined: Sep 25, 2019 10:32 am
Full Name: Oleg Feoktistov
Contact:

Re: Questions on API and how it works for End User GUI (#04316494)

Post by oleg.feoktistov » 1 person likes this post

Yes, X-RestSvcSessionId is a key in response headers of the request to /api/sessionMngr/?v=latest. I guess, you might be looking at request headers instead, but the one you need is beside Body and Cookies nodes.
Should be available along with Set-Cookie key. Thanks!
chris.arceneaux
VeeaMVP
Posts: 667
Liked: 358 times
Joined: Jun 24, 2019 1:39 pm
Full Name: Chris Arceneaux
Location: Georgia, USA
Contact:

Re: Questions on API and how it works for End User GUI (#04316494)

Post by chris.arceneaux » 1 person likes this post

Glad to hear you are using Postman! I enjoy using it as well. Here's a Postman collection I wrote for Enterprise Manager that I think will help you:
If you have questions on how to use this collection and convert the Postman API calls into usable code for a script, here's a recorded webinar speaking on the topic (~15 minutes):
DTTS
Novice
Posts: 4
Liked: never
Joined: Jul 01, 2020 8:03 am
Full Name: Dickson Tan
Contact:

Re: Questions on API and how it works for End User GUI (#04316494)

Post by DTTS »

Hi Oleg,

I have already follow the few steps as given but until i press the "send" link button in postman, then it will ask me to access
(https://<Enterprise-Manager>:9398/api/backupServers) with the user name and password as required in the URL. Unfortunately, it cant be access and i do not know why and then i try to access the Veeam Backup Enterprise Manager on my desktop and key in the same id and password can be access.
Is this consider two different access? Thank You
DTTS
Novice
Posts: 4
Liked: never
Joined: Jul 01, 2020 8:03 am
Full Name: Dickson Tan
Contact:

Re: Questions on API and how it works for End User GUI (#04316494)

Post by DTTS »

Hi Chris,

Thank you for helping me a hand, So at the last step here (https://github.com/VeeamHub/veeam-postm ... se_manager) where should I go and set the variables? Also, the script after it generate from the postman, is it directly got the user interface and i just use a scripting software to run the code?
oleg.feoktistov
Veeam Software
Posts: 1912
Liked: 635 times
Joined: Sep 25, 2019 10:32 am
Full Name: Oleg Feoktistov
Contact:

Re: Questions on API and how it works for End User GUI (#04316494)

Post by oleg.feoktistov »

Dickson,

Access to the resources is session-based. As soon as you send username and password to /api/sessionMngr/?v=latest endpoint, authentication token is created (X-RestSvcSessionId). So, you use it in subsequent calls. Just put X-RestSvcSessionId with its value to request headers.
Feel free to appeal to Postman documentation to write test scripts, set environmental/global variables and use them in your API tests.
For my EM environment I use the following test snippet in a request to /api/sessionMngr/?v=latest:

Code: Select all

tests["Status code is 201"] = responseCode.code === 201;

pm.test("X-RestSvcSessionId is present", () => {
  pm.response.to.have.header("X-RestSvcSessionId");
});

pm.test("Environmental variable has been updated", () => {
    var headers = pm.response.headers.get("X-RestSvcSessionId");
    pm.environment.set("bearer", headers);
});
It updates bearer variable automatically and all you need is just add it as a value to X-RestSvcSessionId request header key.
For working with environmental variables refer to this guide.
wrote:Also, the script after it generate from the postman, is it directly got the user interface and i just use a scripting software to run the code?
No, postman generates code related to request calls. So, you still need to write the rest of frontend part.

Thanks,
Oleg
Post Reply

Who is online

Users browsing this forum: No registered users and 4 guests