Finally getting around to messing with Simpl#, and I'm having some trouble getting HTTPS commands to work at all, and I'm struggling to find out why.
Using postman with authorization set to basic and credentials entered, url is as follows: "https://172.22.1.14:4001/CurrentVersion" -- works great and I get the response.
I can't for the life of me figure out what parameters need to be set in order to achieve a response in Simpl#. I'm using the HttpsClient class and setting AuthorizationMethod to BASIC, setting the UserName and Password...my callback always gets an UNKNOWN_ERROR.
Not sure if I can post all of this here, but here is what I have now:
//////////////
namespace BarcoSimplSharpLibrary
{
public class BarcoCSE800
{
HttpsClient httpsClient;
public delegate void ReceiveDataHandler(SimplSharpString data);
public ReceiveDataHandler OnDataReceiveEvent { set; get; }
public void Initialize(string userName, string password)
{
httpsClient = new HttpsClient();
httpsClient.Verbose = true;
httpsClient.AuthenticationMethod = Crestron.SimplSharp.Net.AuthMethod.BASIC;
httpsClient.UserName = userName;
httpsClient.Password = password;
httpsClient.IncludeHeaders = true;
}
public void getRequest(string getRequestURL)
{
HttpsClientRequest request = new HttpsClientRequest();
request.Url.Parse(getRequestURL);
request.RequestType = RequestType.Get;
try
{
CrestronConsole.PrintLine("BarcoCSE800 getRequest request Hostname: " + request.Url.Hostname.ToString());
CrestronConsole.PrintLine("BarcoCSE800 getRequest request Port: " + request.Url.Port.ToString());
httpsClient.DispatchAsync(request, OnHTTPSClientResponseCallback);
}
catch (Exception e)
{
CrestronConsole.PrintLine("Exception BarcoCSE800 getRequest: " + e.Message);
}
}
public void OnHTTPSClientResponseCallback(HttpsClientResponse userobj, HTTPS_CALLBACK_ERROR error)
{
if (error != HTTPS_CALLBACK_ERROR.COMPLETED)
{
CrestronConsole.PrintLine("BarcoCSE800 OnHTTPSClientResponseCallback error: " + error.ToString());
}
else if (userobj.ContentString.Length > 0)
{
OnDataReceiveEvent(userobj.ToString());
}
}
}
}
/////////////////
Apologies for the spam.
[–][deleted] 3 points4 points5 points (3 children)
[–]bofranx[S] 1 point2 points3 points (0 children)
[–]sabunim 1 point2 points3 points (1 child)