REST API knowledge exchange
dannordquist
Enthusiast
Posts: 27 Liked: 2 times
Joined: Oct 23, 2014 3:39 pm
Full Name: Dan Nordquist
Contact:
Post
by dannordquist » Oct 23, 2014 3:49 pm
this post
I've tried many variations of code but this is the gist:
Code: Select all
HttpWebRequest httpWReq = (HttpWebRequest)HttpWebRequest.Create("http://mysite:9399/api/sessionMngr/");
httpWReq.Method = "POST";
ASCIIEncoding encode = new ASCIIEncoding();
string _auth = string.Format("{0}:{1}", "user", "pass");
string _enc = Convert.ToBase64String(encode.GetBytes(_auth));
string _cred = string.Format("{0} {1}", "Basic", _enc);
byte[] data = encode.GetBytes(_cred);
httpWReq.ContentLength = _cred.Length;
httpWReq.Headers[HttpRequestHeader.Authorization] = _cred;
string responseString = new StreamReader(httpWReq.GetResponse().GetResponseStream()).ReadToEnd();
Console.WriteLine(responseString);
I get a 500 error from the server.
Any ideas?
Thanks!
dannordquist
Enthusiast
Posts: 27 Liked: 2 times
Joined: Oct 23, 2014 3:39 pm
Full Name: Dan Nordquist
Contact:
Post
by dannordquist » Oct 23, 2014 4:21 pm
this post
I've replied to several posts with related comments and they are getting deleted.
Does Veeam not want this to be successful or just want to frustrate everyone who's looking for answers?
dannordquist
Enthusiast
Posts: 27 Liked: 2 times
Joined: Oct 23, 2014 3:39 pm
Full Name: Dan Nordquist
Contact:
Post
by dannordquist » Oct 23, 2014 4:33 pm
this post
Here's the header text being sent to the server, which is exactly the correct format specified in the documentation:
Content-Type: text/xml
Authorization: Basic dmVlYW06VjMzYU0yMDEx
Still get a 500 error though...
veremin
Product Manager
Posts: 20414 Liked: 2302 times
Joined: Oct 26, 2012 3:28 pm
Full Name: Vladimir Eremin
Contact:
Post
by veremin » Oct 23, 2014 4:33 pm
this post
Your post were deleted, because they were the same. Meanwhile, your original topic has been preserved. Please, don't overfill multiple topics with the same issue, and keep posting in this thread.
Thank you for your understanding.
dannordquist
Enthusiast
Posts: 27 Liked: 2 times
Joined: Oct 23, 2014 3:39 pm
Full Name: Dan Nordquist
Contact:
Post
by dannordquist » Oct 23, 2014 4:35 pm
this post
I posted on several threads because people will get notification of the post, and if they found an answer it might prompt them to post it.
Posting a new thread does not notify people who have the same question.
Thank you for making this more difficult.
poulpreben
Certified Trainer
Posts: 1025 Liked: 448 times
Joined: Jul 23, 2012 8:16 am
Full Name: Preben Berg
Contact:
Post
by poulpreben » Oct 24, 2014 2:22 pm
this post
Hi Dan,
You probably want to have a look at this thread over at StackOverflow:
C# webrequest authentication
I would love to try, but I never did much C# programming, so please post your findings in this thread!
Thanks,
Preben
dannordquist
Enthusiast
Posts: 27 Liked: 2 times
Joined: Oct 23, 2014 3:39 pm
Full Name: Dan Nordquist
Contact:
Post
by dannordquist » Oct 24, 2014 2:31 pm
this post
Thanks poulpreben. I've found that there's nothing wrong with my code, however. It works just fine, but the server returns a 500 error because we don't have the Enterprise Plus license. It doesn't indicate anything about licensing or why it got the 500 error, so it was difficult to find that it was just a licensing issue (wasted two days thinking it was a code issue).
Looks like it's a bit costly for the Plus license so if we can't get budget for it I'll end up figuring out the DB structure and parsing the Database instead. Won't be able to do anything but read information but better than nothing.
veremin
Product Manager
Posts: 20414 Liked: 2302 times
Joined: Oct 26, 2012 3:28 pm
Full Name: Vladimir Eremin
Contact:
Post
by veremin » Oct 24, 2014 2:36 pm
this post
What about using PowerShell, instead of parsing DB? Not only will be more convenient, from my perspective, but also it will not be read-only stuff, as changes are totally possible via PS. Thanks.
dannordquist
Enthusiast
Posts: 27 Liked: 2 times
Joined: Oct 23, 2014 3:39 pm
Full Name: Dan Nordquist
Contact:
Post
by dannordquist » Oct 24, 2014 2:42 pm
this post
Thank you v.Eremin. Would you mind posting some example PS code to get me started on the right path? Just login and reading data (current jobs with failure/warnings and job duration would be awesome) will get me started and then I hope to find information on adding commands and/or changes after proving the functionality.
veremin
Product Manager
Posts: 20414 Liked: 2302 times
Joined: Oct 26, 2012 3:28 pm
Full Name: Vladimir Eremin
Contact:
Post
by veremin » Oct 24, 2014 3:01 pm
this post
The best idea would be to check both
PowerShell subforum and
our online Help Center.
As to the script examples, the following ones should be helpful:
Get all jobs that failed during the last run
Code: Select all
Asnp VeeamPSSnapin
Get-VBRJob | where {$_.GetLastResult() -eq "Failed"}
Select all jobs along with the start and end time of their latest sessions:
Code: Select all
Asnp VeeamPSSnapin
Get-VBRJob | select name, {$_.Findlastsession().creationTime}, {$_.Findlastsession().EndTime}
If you want to continue discussion regarding PS, please, create a separate topic on the said subforum.
Thanks.
dannordquist
Enthusiast
Posts: 27 Liked: 2 times
Joined: Oct 23, 2014 3:39 pm
Full Name: Dan Nordquist
Contact:
Post
by dannordquist » Oct 24, 2014 3:29 pm
this post
Excellent! thank you!
veremin
Product Manager
Posts: 20414 Liked: 2302 times
Joined: Oct 26, 2012 3:28 pm
Full Name: Vladimir Eremin
Contact:
Post
by veremin » Oct 27, 2014 7:17 am
this post
You're welcome. Should other questions arise, feel free to contact us. Thanks.
Users browsing this forum: No registered users and 3 guests