How to get Teamviewer device's online state by api with C#?

55 views Asked by At

I'm trying to make the C# program that can check Teamviewer device's online state.

I already made the Token that allows all the authentication about teamviewer.
I'm finding Teamviewer's official API to get the online information about specific teamviewer ID that my device own.
For example, If i have the Teamviewer device which id is "111 111 111", I want to check if the device is online by C# program.

Teamviewer API Document

I tried to find about it here but failed.
Here is my sample code.

static void Main(string[] args) {
 string accessToken = "xxxxxxxxxxxxxxxxxxx";
 string apiVersion = "v1";
 string tvApiBaseUrl = "https://webapi.teamviewer.com";
 string address = tvApiBaseUrl + "/api/" + apiVersion + "/reports/connections";

 try
 {
     // Create the web request  
     HttpWebRequest request = WebRequest.Create(address) as HttpWebRequest;
     request.Headers.Add("Authorization", "Bearer " + accessToken);
     request.Method = "GET";
     WebResponse webResp = request.GetResponse();
 }
 catch (Exception)
 {
     // Do nothing for now
 } }

When i run this program, 401 error occured at this code line.

WebResponse webResp = request.GetResponse();  

I just tried to use '/reports/connections' without checked if it used for checking online state.
Do you guys know how to do it??
Sorry for my noob explanation.
Regards

0

There are 0 answers