0

I am trying to write an https Post with the data duration=300. I am new to C# and am writing in a sandbox for another program called Crestron Simpl#. If anyone could help point me in the right direction for adding the data to the Post. Thanks

 public void post(String postVar) { try { var httpsSet = new HttpsClient(); httpsSet.KeepAlive = false; httpsSet.Accept = "application/xml"; httpsSet.UserName = username; httpsSet.Password = password; httpsSet.HostVerification = false; httpsSet.PeerVerification = false; HttpsClientRequest sRequest = new HttpsClientRequest(); sRequest.RequestType = RequestType.Post; sRequest.Url.Parse("https://" + ipaddress + postVar); HttpsClientResponse response = httpsSet.Dispatch(sRequest); string responseRx = response.ContentString; ushort iRepsonse = myRx(responseRx); } catch (Exception e) { CrestronConsole.PrintLine(String.Format("{0} exception", e.Message)); } } 
3
  • What is "HttpsClient" ? Commented Jul 27, 2016 at 14:51
  • It is Crestron Sandboxes way of handling Https. Commented Jul 27, 2016 at 14:57
  • Never heard of it, probably this : crestron.com/reference/simpl_sharp/html/… Commented Jul 27, 2016 at 15:00

1 Answer 1

0

Here's a sample C# snippet for a PUT request.

HttpWebRequest HttpWReq = (HttpWebRequest) WebRequest.Create("http:\\YourDomain.com"); ASCIIEncoding Encoding = new ASCIIEncoding(); byte[] data = Encoding.GetBytes("Put you data here"); HttpWReq.Method = "PUT"; HttpWReq.ContentType = "Enter your MIME type"; HttpWReq.ContentLength = data.Length; //Then when you actually want to write the request, perform these functions: Stream NewStream = HttpWReq.GetRequestStream(); NewStream.Write(data, 0, data.Length); NewStream.Close(); 

You can read more into other answers here.

Sign up to request clarification or add additional context in comments.

1 Comment

He is using a custom class from Crestron, not from MS.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.