I have to implement Screen Sharing in a MVC application, for that I am trying to use Screenleap service. To make request to screenleap I have added following code:

string url = "https://api.screenleap.com/v1/screen-shares?accountid=myAccountID&authtoken=myTokenNumber";

        HttpWebRequest request = (HttpWebRequest)WebRequest.Create(url);
        request.Method = "POST";
        HttpWebResponse response = (HttpWebResponse)request.GetResponse();

        Stream resStream = response.GetResponseStream();

But it is returning Error: The remote server returned an error: (401) Unauthorized.

Can anyone help how to solve this issue i.e. how to get connected to screenleap with MVC application OR any good alternative for screen sharing?

有帮助吗?

解决方案

Try the following:

        string url = "https://api.screenleap.com/v1/screen-shares";
        HttpWebRequest request = (HttpWebRequest)WebRequest.Create(url);
        request.Method = "POST";
        request.Headers.Add("accountId", "myAccountID");
        request.Headers.Add("authtoken", "myTokenNumber");
        HttpWebResponse response = (HttpWebResponse)request.GetResponse();
        Stream resStream = response.GetResponseStream();
        StreamReader reader = new StreamReader(resStream);
        string responseFromServer = reader.ReadToEnd();
        Console.WriteLine(responseFromServer);

Works for me. Hope that helps.

许可以下: CC-BY-SA归因
不隶属于 StackOverflow
scroll top